Using Applescript to batch convert files.

Up until MacVector 13 Applescript support was fairly limited. However, with this release we’ve started to expand it. The first enhancement has been to improve the export of files. Now you can export files to any supported format. Over the next few releases this support will be further expanded to include some analysis tools. If a particular tool would be helpful for you please do let us know.

There’s an Applescript folder in the MacVector Application folder. This contains two very simple scripts to use to build your own.

One of the scripts will batch convert a folder of sequences into Genbank format. Here’s a modified version of that script with these changes:

  • Use the filename as the new Locus
  • Optionally concatenate all the files to a single multi sequence file
  • Convert to either Fasta or Genbank.
  • Produce a summary of all files converted
  • Screenshot 23 05 2014 12 51

    The script is too long to place here but the relevant MacVector part of the code is here:

    	if mvExtension = "nucl" then
    		tell application "MacVector"
    			--Now open the file
    			open f
    			delay 0.3 -- wait a little bit until MV has opened the file
    			--now save it as a genbank file
    			set docRef to (a reference to the first document)
    			if SeqFormat = "fasta" then
    				save docRef in outputFilePath as FASTA
    			else
    				save docRef in outputFilePath as GenBank
    			end if
    			close docRef
    		end tell
    		
    

    Download the full script here.

    Many thanks to Chris Buck for all his invaluable feedback on this script.

    If you have any useful scripts please let us know.

    This entry was posted in Tips and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.