// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! This script is provided "as is" by Applied Maths. ! // ! You are free to use and modify this script for your own needs. ! // ! Redistribution or reproduction of the script is prohibited. ! // ! DISCLAIMER: ! // ! Improper use of scripts may corrupt your database. ! // ! Running this script is entirely at your own responsibility. ! // ! Applied Maths accepts no lialibility for any consequences ! // ! resulting from its use. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //$DISPLAY_COMPWIN DIALOG dlg; string expername,str_minsim,str_minct; string fieldlist,fieldname,clustername,key; float minsim,simil,signif; integer subct,collapsed,cutoff,minct,i,j; integer ok,ok2,nr,save; BRANCH root,bra,bra2; integer clucount,cluentrycount[],cluentry[][]; if not(CmpIsPresent) then CmpAttach; if not(CmpIsPresent) then { message("Unable to attach a comparison to this script"); stop; } expername=CluGetCurrent; ok=CluGetRoot(expername,root); if (expername="") or (not(ok)) then { message("There is currently no clustering displayed"); stop; } //Fill parameters str_minsim=TempRecall("clu_cutoff_threshold_minsim"); str_minct=TempRecall("clu_cutoff_threshold_minct"); if str_minsim="" then str_minsim="100"; if str_minct="" then str_minct="1"; fieldname=TempRecall("clu_cutoff_fieldname"); for i=1 to DbGetFieldCount do fieldlist=fieldlist+DbGetFieldName(i)+" "; if fieldname="" then fieldname=fieldlist;fieldname=splitstring(fieldname," "); if TempRecall("clu_cutoff_saveresults")<>"" then save=val(TempRecall("clu_cutoff_saveresults")); else save=1; //prompt user for parameters DlgAddText(dlg,"Cut off clusters below ",15,15,110,15); DlgAddEdit(dlg,str_minsim,135,15,50,20); DlgAddText(dlg,"% similarity",190,15,70,15); DlgAddText(dlg,"Clusters must have at least",15,50,140,15); DlgAddEdit(dlg,str_minct,160,50,40,20); DlgAddText(dlg,"members",210,50,50,15); DlgAddText(dlg," Write cluster number to:",15,100,140,15); DlgAddList(dlg,fieldlist,fieldname,15,120,140,150,"LIST"); DlgAddCheck(dlg,"Save fields",save,15,280,140,15); if not(DlgShow(dlg,"Fill field with cluster number",280,340)) then stop; TempStore("clu_cutoff_threshold_minsim",str_minsim); TempStore("clu_cutoff_threshold_minct",str_minct); TempStore("clu_cutoff_fieldname",fieldname); TempStore("clu_cutoff_saveresults",str(save,0,0)); minsim=val(str_minsim); minct=val(str_minct); clucount=0; setbusy("Visiting all clusters..."); ok=CluEnumStart(root,bra); while ok do { CluGetInfo(bra,simil,signif,subct,collapsed,cutoff); cutoff=(simil0 then { nr=cluentrycount[clucount]+1;cluentrycount[clucount]=nr; cluentry[clucount][nr]=CluGetEntryNr(bra2); } ok2=CluEnumNext(bra2); } CluEnumSkip(bra); } ok=CluEnumNext(bra); } setbusy(""); for i=1 to CmpGetEntryCount do DbSetField(CmpGetEntryKey(i),fieldname,""); for i=1 to clucount do { clustername=str(i,0,0);while length(clustername)<4 do clustername="0"+clustername; for j=1 to cluentrycount[i] do { nr=cluentry[i][j]; key=CmpGetEntryKey(nr); DbSetField(key,fieldname,clustername); } } if save then DbSaveFields;