-- Jun. 8 2004. -- written by F.Damberger -- Writes out a Textfile with the results from a batch integration -- The elements are separated by ';' for easy import in Excel / OpenOffice -- first line gives the names of the spectra -- following lines give the Peak Label (comment) and a list of intensities for each spectrum -- Hint: If you want the first line to give the parameter thats varied for each spectrum (e.g NOE mixing time) -- then rename your spectra to the corresponding value (spectrum 1 -> 50, spectrum 2 -> 100, spectrum 3 -> 200 ...) -- Another option is to create a new attribute for spectra (e.g. MixTime) and assign the correct value to each spectrum -- Then rewrite the script to get the attribute value instead of the Spectrum Name -- In the section "write out titles for columns": -- comment out the line to write the spectrum name: getName() -- comment in the line to write out the spectrum attribute: getAttr("MixTime") -- ------------------------------------------------------------------------------------------------------------------- t={} -- Get Parameters from User -- 1. Get Project: ------------------------------------------------ local projectnames = {} i=0 for a,b in pairs( cara:getProjects() ) do i = i + 1 projectnames[ i ] = a end if i==1 then t.ProjectName = projectnames[ i ] else t.ProjectName = dlg.getSymbol( "Choose project", "select one", unpack( projectnames ) ) end t.Project=cara:getProject( t.ProjectName ) -- 2. Get Output filename: ----------------------------------------- t.FileName = dlg.getText( "Enter output filename", "output filename","batchtable.txt" ) -- 3. Get PeakList: ------------------------------------------------ local PeakListNames = {} local PeakListIds = {} i=0 for a,b in pairs( t.Project:getPeakLists() ) do i=i+1 PeakListIds[ i ] = b:getId() PeakListNames[ i ] = b:getId()..":"..b:getName() end if i==1 then t.PeakListName = PeakListNames[ 1 ] else t.PeakListName = dlg.getSymbol("Choose Peaklist","select one", unpack( PeakListNames ) ) end for i=1,table.getn( PeakListNames ) do if t.PeakListName == PeakListNames[ i ] then t.PeakListId = PeakListIds[ i ] end end -- Get PeakList and Write out Batch Table -------------------------- t.peaklist=t.Project:getPeakList( t.PeakListId ) t.spectra={} t.batchlist=t.peaklist:getBatchList() local specID,spectrum for specID,spectrum in pairs( t.batchlist ) do t.spectra[ specID ]=t.Project:getSpectrum( t.batchlist[ specID ] ) end file = io.open( t.FileName, "w" ) -- write out titles for columns ------------------------------------ t.list="comment" for specID,spectrum in pairs( t.batchlist ) do t.list = t.list..";"..t.spectra[ specID ]:getName() -- t.list = t.list..";"..t.spectra[ specID ]:getAttr("MixTime") end t.list=t.list.."\n" file:write( t.list ) -- write out peak number and intensities --------------------------- for peakID,peak in pairs( t.peaklist:getPeaks() ) do t.list = peak:getLabel() for specID,spectrum in pairs( t.batchlist ) do t.list = t.list..";"..peak:getVol( t.spectra[ specID ]) end t.list = t.list.."\n" file:write( t.list ) end file:flush() file:close() t = nil