Created
February 17, 2011 05:10
-
-
Save seandavi/831017 to your computer and use it in GitHub Desktop.
Python wrapper around SymD executable and xml tool description for running behind galaxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<tool id="symd_tool" name="Perform SymD calculation on a PDB file"> | |
<description>Use this tool to run symd on a PDB file</description> | |
<command interpreter="python">symd_wrapper.py $input $trfm_file $info_file ${input.name} </command> | |
<inputs> | |
<param format="txt" name="input" type="data" label="PDB file"/> | |
</inputs> | |
<outputs> | |
<data format="txt" name="trfm_file" /> | |
<data format="txt" name="info_file" /> | |
</outputs> | |
<help> | |
This tool simply runs SymD on the input file. | |
</help> | |
</tool> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
import sys | |
import tempfile | |
import shutil | |
# This is the name from galaxy for the input .pdb file | |
# Unfortunately, it has a name that ends in .dat | |
fname = sys.argv[1] | |
# These are the names of the datafiles supplied by galaxy | |
# for storing the output. | |
outfname1 = sys.argv[2] | |
outfname2 = sys.argv[3] | |
# this is the original filename | |
origfname = sys.argv[4] | |
# We simply symlink the galaxy system filename to the original | |
# filename to get SymD the protein name and the .pdb extension | |
os.symlink(fname,origfname) | |
# These are the names of the output files as created by | |
# SymD. We will need to copy these files back to | |
# outfname1 and outfname2 above. | |
symdinfofname = os.path.splitext(origfname)[0] + "-info.txt" | |
symdpdbfname = os.path.splitext(origfname)[0] + "-trfm.pdb" | |
# Call SymD with the symlinked file ending with .pdb | |
symdcmd = "SymD %s" % origfname | |
res = subprocess.call(symdcmd,stderr=subprocess.PIPE,stdout=subprocess.PIPE,shell=True) | |
if(res<>0): | |
print(stderr) | |
else: | |
# Finally, copy the output files from SymD back to the data files. | |
shutil.copy(symdinfofname,outfname1) | |
shutil.copy(symdpdbfname,outfname2) |
Unfortunately ${input.name} is a job name and ONLY in case of file upload happens to be the original file name. If you feed an output from ANOTHER tool as input for this tool - it will be something like "<TOOL-NAME on data XX".
So this script only works on uploaded data.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use these two files: