option explicit Dim compo, compoxml, fso, f, ts, filename, lines, filepath, filenametarget, g, gso, gs, haeppchen, targetpath, targetmgf,t, headerexist, latestAnalysis Dim compString, LineArray, IsTitleline, myanalysis,answer, isMSScan, MSScan, isMSMSScan, MSMSScan filepath = Analysis.path filename = Analysis.name filenametarget = split (filename,".d",-1,1) 'targetpath = Split(filepath, filename,-1,1) targetpath = filepath analysis.save 'analysis.export filepath&"\"&filenametarget(0)&".mzXML",damzXML"' analysis.chromatograms.add daBPC,daAllMS,"50-1221; 1225-3000", daBoth create_mgf form.close Sub create_mgf Dim i, hso, h, b Analysis.ProcessAutoMSn create_combined_file "Proteinanalysisresults.mgf", filenametarget(0)&".mgf" End Sub Sub copy_to_supervised (filename,targetfolder) Dim hso Set hso = CreateObject("Scripting.FileSystemObject") hso.copyFile targetpath &"\"& filename, targetfolder End Sub Sub create_combined_file (mgf_filename, targetfile) Dim i, rt, rtparts headerexist=false Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filepath &"\"& mgf_filename) Set ts = f.openAsTextStream(1,0) 'targetpath = Split(filepath, filename,-1,1) ' If ts.read(6)= "CHARGE" Then lines = 14 Else lines = 13 ' ts.close Set f = fso.GetFile(filepath &"\" & mgf_filename) Set ts = f.openAsTextStream(1,0) Set gso = CreateObject("Scripting.FileSystemObject") If gso.fileexists(targetpath&"\"&targetfile) Then gso.deletefile (targetpath&"\"&targetfile) End IF 'Else gso.CreateTextFile (targetpath&"\"&targetfile) Set g = gso.GetFile (targetpath&"\"&targetfile) Set gs = g.OpenAsTextStream(8,0) while left(ts.readline,3) <> "###" ts.skipline wend while ts.atendofstream <> true compString = ts.readline isMSScan = Instr(1,compstring, "###MS:" ,1) If isMSScan <> 0 then MSScan = right(compstring, len(compstring)-6) isMSMSScan = Instr(1,compstring, "###MSMS:" ,1) If isMSMSScan <> 0 then MSMSScan = right(compstring, len(compstring)-8) isTitleline = Instr(1,compstring, "TITLE" ,1) If isTitleline <> 0 Then LineArray = Split(CompString,"=", -1, 1) rtparts = split(Compstring,chr(32),-1,1) ' msgbox rtparts(3) if rtparts(5) = "s" then rt = cdbl(rtparts(4)) else rt = cdbl(rtparts(4) * 60) end if gs.writeline "RTINSECONDS="&rt gs.writeline "SCANS=MS:" &MSSCAN&" MSMS:" &MSMSScan compstring = LineArray(0)&"="& LineArray(1)& " MS:"&MSSCAN&" MSMS:"&MSMSScan End If gs.writeline (compstring) wend ts.close gs.close End Sub