// From a comparison with a sequence type experiment, the sequences on display // are exported without gaps in a tab-delimited text format. // The script pops up a dialog box that asks to check the information fields you want to export. //************************************************************* // Sample script provided "as is" by Applied Maths. // You are free to use and modify this script for your // own purposes. // Please notice that improper use of script commands may // corrupt your database. Running this script is entirely at // your own responsibility. Applied Maths accepts no // liability for any damage that results from using // this script. //************************************************************* //$MENU window=comparison;popup=sequence;insertafter=Show global cluster analysis;name=Export sequences without gaps DIALOG dlg; string fieldlist,fieldsel,filename,key,st,st1,experlist,expername,seqstr,expcl,seqput; sequence sq; integer i,count; FILE fp; // check for presence of comparison if not(CmpIsPresent) then CmpAttach; if not(CmpIsPresent) then { message("No comparison is currently open"); stop; } // get list of information fields fieldlist="Key "; for i=1 to DbGetFieldCount do fieldlist=fieldlist+DbGetFieldName(i)+" "; fieldsel="Key"; for i=1 to DbGetExperCount do if DbGetExperClass(i)="SEQ" then experlist=experlist+DbGetExperName(i)+" "; expername=experlist;expername=splitstring(expername," "); DlgAddText(dlg,"Select the field(s) you want to export",20,20,180,15); DlgAddList(dlg,fieldlist,fieldsel,20,40,180,150,"MULTI"); DlgAddText(dlg,"Select the Sequence Type",220,20,150,15); DlgAddList(dlg,experlist,expername,220,40,150,150,"LIST"); if not(DlgShow(dlg,"Export sequences",490,250)) then stop; filename=DbGetPath+"\export.txt"; if not(FileOpenWrite(fp,filename)) then { message("ERROR: unable to create export file"); stop; } // scan all entries in comparison count=CmpGetEntryCount; for i=1 to CmpGetEntryCount do { seqput=""; seqstr=""; key=CmpGetEntryKey(i); st=fieldsel; // get information fields while st<>"" do { st1=splitstring(st," "); if st1="key" then seqput = seqput+key+" "; if st1<>"key" then seqput = seqput+DbGetField(key,st1)+" "; } // check if sequence is present for entry and get sequence if DbGetEntryLink(key,expername) <> "" then { seqstr = CmpSeqGet(expername,i); while find(seqstr," ",1)>0 do { seqstr=splitstring(seqstr," ")+seqstr; } seqput=seqput+" "+seqstr; // export sequence FileWrite(fp,seqput+"~n"); } } FileClose(fp); // show file with sequences execute("notepad.exe "+DbGetPath+"\export.txt");