Mercurial > repos > bgruening > molecule2gspan
changeset 0:18eb78773d87 draft
Uploaded
author | bgruening |
---|---|
date | Tue, 29 Oct 2013 11:15:59 -0400 |
parents | |
children | 5f97004c7f57 |
files | mol2gspan.py mol2gspan.xml readme.rst repository_dependencies.xml tool_dependencies.xml |
diffstat | 5 files changed, 152 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mol2gspan.py Tue Oct 29 11:15:59 2013 -0400 @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +""" + Converts a SD-file to a GSPAN file. +""" + + +import os, sys +import argparse + +def main( args ): + + begin = False + iid = 0 + graph_counter = 1 + + for line in args.infile: + if line.rstrip(): + if line.strip().endswith('END'): + begin = False + elif line.strip() == '$$$$': + graph_counter += 1 + iid = 0 + else: + # found header line, like: 21 21 0 0 0 0 0 0 0 0999 V2000 + if len(line.split()) >= 5 and line.split()[-1] == 'V2000': + args.outfile.write('t # id %s\n' % graph_counter) + begin=True + continue + # connection or coordinate/atom table + if len(line.split()) >= 4 and begin: + # coordinate/atom table + if not line.startswith('M'): + if line.split()[3].isalpha() or line.split()[3] == '*': + args.outfile.write( 'v %s %s \n' % (iid, line.split()[3]) ) + iid += 1 + else: + #connection table + id, node, edge, trash = line.split(None, 3) + args.outfile.write( 'e %s %s %s\n' % ( int(id) - 1 , int(node) -1, edge ) ) + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('--infile', nargs='?', type=argparse.FileType('r'), + default=sys.stdin, help="Specify one or more input files") + parser.add_argument('--outfile', type=argparse.FileType('w'), + default=sys.stdout, help="Specify one output file") + args = parser.parse_args() + main( args )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mol2gspan.xml Tue Oct 29 11:15:59 2013 -0400 @@ -0,0 +1,41 @@ +<tool id="bg_mol2gspan" name="Molecule to gSpan" version="0.1"> + <description>converter</description> + <parallelism method="multi" split_inputs="infile" split_mode="to_size" split_size="10" shared_inputs="" merge_outputs="outfile"></parallelism> + <requirements> + <requirement type="package" version="2.3.2">openbabel</requirement> + <requirement type="set_environment">MOL2GSPAN_SCRIPT_PATH</requirement> + </requirements> + <command> + + #if $infile.ext == 'sdf': + python \$MOL2GSPAN_SCRIPT_PATH/mol2gspan.py --infile $infile --outfile $outfile + + #else: + obabel -i $infile.ext -o sdf $infile ---errorlevel 1 | python \$MOL2GSPAN_SCRIPT_PATH/mol2gspan.py --infile - --outfile $outfile + + #end if + + </command> + <inputs> + <param format="smi,sdf,mol,inchi,mol2" name="infile" type="data" + label="Input molecules" help=""/> + </inputs> + <outputs> + <data format="gspan" name="outfile" label="gSpan from ${on_string}"/> + </outputs> + <tests> + <test> + <param name="infile" value="3_molceuls.sdf" /> + <output name="outfile" file="3_molecules.gspan" /> + </test> + </tests> + <help> + +.. class:: infomark + +**What it does** + +That converter will convert arbitratry molecule files to the gSpan format. + + </help> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/readme.rst Tue Oct 29 11:15:59 2013 -0400 @@ -0,0 +1,48 @@ +Galaxy wrapper for mol2gspan +============================ + +This wrapper is copyright 2013 by Björn Grüning. + +This is a wrapper for the command line tool of mol2gspan. + + + + +Installation +============ + +The recommended installation is by means of the toolshed_. +If you need to install it manually here is a short introduction. + +.. _toolshed: http://toolshed.g2.bx.psu.edu/view/bgruening/molecule2gspan + + + +History +======= + +- v0.1: Initial public release + + +============= +Licence (MIT) +============= + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/repository_dependencies.xml Tue Oct 29 11:15:59 2013 -0400 @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<repositories description="This requires the Molecule datatype definitions (e.g. SMILES, InChI, SD-format) and the EDeN datatypes."> + <repository changeset_revision="8714f927a6ee" name="molecule_datatypes" owner="iuc" toolshed="http://testtoolshed.g2.bx.psu.edu" /> + <repository changeset_revision="59b3b6ce10bb" name="eden_toolbox" owner="bgruening" toolshed="http://testtoolshed.g2.bx.psu.edu" /> +</repositories>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_dependencies.xml Tue Oct 29 11:15:59 2013 -0400 @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="openbabel" version="2.3.2"> + <repository changeset_revision="7601c962048a" name="package_openbabel_2_3" owner="iuc" toolshed="http://testtoolshed.g2.bx.psu.edu" /> + </package> + <set_environment version="1.0"> + <environment_variable action="set_to" name="MOL2GSPAN_SCRIPT_PATH">$REPOSITORY_INSTALL_DIR</environment_variable> + </set_environment> +</tool_dependency>