# HG changeset patch # User bgruening # Date 1368306705 14400 # Node ID 12822efbd4a40e1cbce3241999b3b610ae7b021b # Parent 9d1f982555baf6b39b6a7a260abaaea2757f1d0f Uploaded diff -r 9d1f982555ba -r 12822efbd4a4 convert/ob_convert.xml --- a/convert/ob_convert.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/convert/ob_convert.xml Sat May 11 17:11:45 2013 -0400 @@ -11,7 +11,9 @@ ## The command is a Cheetah template which allows some Python based syntax. ## Lines starting hash hash are comments. Galaxy will turn newlines into spaces - #if str($out_format) == 'fs': +#set $format = $oformat.oformat_opts_selector + + #if $format == "fs": ## For the fastsearch index we need to copy the original molecule files to the composite datatype of obfs. ## Because openbabel likes file extensions, we give the molecule file a proper file extension. mkdir $outfile.extra_files_path; @@ -19,129 +21,395 @@ #end if obabel -i "${infile.ext}" - #if str($out_format) == 'fs': + + #if $format == "fs": + ## the fs filetype need his own symlink path, all others can take the original ones ${os.path.join($outfile.extra_files_path, 'molecule.%s' % $infile.ext )} - -o "${out_format}" -e + -o "$format" -e -O ${os.path.join($outfile.extra_files_path,'molecule.fs')} + #if int($oformat.fs_fold) > 0: + $oformat.fs_fold + #end if + -xN$#str(${oformat.fs_fptype}).strip() #else: "${infile}" - -o "${out_format}" -e + -o "$format" -O "${outfile}" + -e + #end if + + + #if $format == 'cml': + $oformat.cml_array + $oformat.cml_cml1 + $oformat.cml_aromatic + $oformat.cml_hydrogen + $oformat.cml_metadata + $oformat.cml_omit + $oformat.cml_continuous + $oformat.cml_properties + #elif $format == 'inchi': + ##ignore less import warnings + -w + #if $oformat.inchi_truncate: + #set $truncate = ''.join( str( $oformat.inchi_truncate ).split( ',' ) ) + -xT ${truncate} + #end if + + #if $oformat.inchi_additional: + #set $additional = ' '.join( str( $oformat.inchi_additional ).split( ',' ) ) + -xX '${additional}' + #end if + + $oformat.inchi_key + $oformat.inchi_name + $oformat.inchi_unique + $oformat.inchi_unique_sort + #elif $format == 'can': + $oformat.can_exp_h + $oformat.can_iso_chi + $oformat.can_rad + $oformat.can_atomclass_out + #elif $format == 'smi': + $oformat.smi_exp_h + $oformat.smi_iso_chi + $oformat.smi_rad + $oformat.smi_atomclass_out + $oformat.smi_can + $oformat.smi_coordinates + #elif $format == 'sdf': + $oformat.sdf_exp_h + $oformat.sdf_no_prop + $oformat.sdf_wedge_bonds + $oformat.sdf_alias_out + #elif $format == 'fpt': + $oformat.fpt_fptype + #if int($oformat.fpt_fold) > 0: + $oformat.fpt_fold + #end if + $oformat.fpt_hex_multiple + $oformat.fpt_hex + $oformat.fpt_set + $oformat.fpt_unset + #elif $format == 'mol2': + $oformat.mol2_ignore_res + #end if + + ## Uniqueness according to stripped InChI's or canonical SMILES + #if str($unique.unique_opts_selector): + #if $unique.unique_opts_selector == 'inchi': + #if $unique.truncate: + #set $truncate = ''.join( str( $unique.truncate ).split( ',' ) ) + --unique $truncate + #end if + #else + --unique $unique.unique_opts_selector + #end if + #end if + + + #if str($appendtotitle).strip(): + --addtotitle '${appendtotitle}' #end if $remove_h - #if $iso_chi or $can or $exp_h: - -x$iso_chi$exp_h$can - #end if - #if $dative_bonds: - -b - #end if + $dative_bonds + #if int($ph) >= 0: -p $ph #end if + 2>&1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - + + + + + + + + + diff -r 9d1f982555ba -r 12822efbd4a4 filter/ob_filter.xml --- a/filter/ob_filter.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/filter/ob_filter.xml Sat May 11 17:11:45 2013 -0400 @@ -50,6 +50,10 @@ + + + + @@ -62,7 +66,8 @@ - + @@ -116,6 +121,9 @@ + diff -r 9d1f982555ba -r 12822efbd4a4 modify/ob_genProp.py --- a/modify/ob_genProp.py Fri Apr 26 11:05:19 2013 -0400 +++ b/modify/ob_genProp.py Sat May 11 17:11:45 2013 -0400 @@ -14,9 +14,9 @@ def parse_command_line(argv): parser = argparse.ArgumentParser() - parser.add_argument('-iformat', default='sdf' , help='input file format') + parser.add_argument('--iformat', default='sdf' , help='input file format') parser.add_argument('-i', '--input', required=True, help='input file name') - parser.add_argument('-oformat', default='sdf', choices = ['sdf', 'table'] , help='output file format') + parser.add_argument('--oformat', default='sdf', choices = ['sdf', 'table'] , help='output file format') parser.add_argument('--header', type=bool, help='Include the header as the first line of the output table') parser.add_argument('-o', '--output', required=True, help='output file name') return parser.parse_args() diff -r 9d1f982555ba -r 12822efbd4a4 modify/ob_genProp.xml --- a/modify/ob_genProp.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/modify/ob_genProp.xml Sat May 11 17:11:45 2013 -0400 @@ -7,8 +7,8 @@ ob_genProp.py -i "${infile}" - -iformat "${infile.ext}" - -oformat "${output_opts.output_format_types}" + --iformat "${infile.ext}" + --oformat "${output_opts.output_format_types}" #if $output_opts.header.value: --header $output_opts.header #end if diff -r 9d1f982555ba -r 12822efbd4a4 repository_dependencies.xml --- a/repository_dependencies.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/repository_dependencies.xml Sat May 11 17:11:45 2013 -0400 @@ -1,4 +1,4 @@ - + diff -r 9d1f982555ba -r 12822efbd4a4 search/ob_spectrophore_search.xml --- a/search/ob_spectrophore_search.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/search/ob_spectrophore_search.xml Sat May 11 17:11:45 2013 -0400 @@ -11,7 +11,7 @@ --column $column - + diff -r 9d1f982555ba -r 12822efbd4a4 subsearch/subsearch.py --- a/subsearch/subsearch.py Fri Apr 26 11:05:19 2013 -0400 +++ b/subsearch/subsearch.py Sat May 11 17:11:45 2013 -0400 @@ -17,6 +17,7 @@ def parse_command_line(): parser = argparse.ArgumentParser() parser.add_argument('-i', '--infile', required=True, help='Molecule file.') + parser.add_argument('--iformat', help='Input format.') parser.add_argument('--fastsearch-index', dest="fastsearch_index", required=True, help='Path to the openbabel fastsearch index.') parser.add_argument('-o', '--outfile', required=True, help='Path to the output file.') @@ -45,7 +46,7 @@ opts = '-o%s' % args.oformat tmp = tempfile.NamedTemporaryFile(delete=False) - cmd = 'obabel %s -O %s %s -ifs -s%s -al %s' % (args.fastsearch_index, tmp.name, opts, query, args.max_candidates) + cmd = 'obabel -ifs %s -O %s %s -s%s -al %s' % (args.fastsearch_index, tmp.name, opts, query, args.max_candidates) child = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -64,12 +65,25 @@ return (tmp.name, query) +def get_smiles_or_smarts( args ): + """ + Wrapper to retrieve a striped SMILES or SMARTS string from different input formats. + """ + if args.iformat in ['smi', 'text', 'tabular']: + with open( args.infile ) as text_file: + for line in text_file: + yield line.split('\t')[0].strip() + else: + # inchi or sdf files + for mol in pybel.readfile( args.iformat, args.infile ): + yield mol.wrtie('smiles').split('\t')[0] + def substructure_search( args ): pool = multiprocessing.Pool( args.processors ) - for query in open( args.infile ): - pool.apply_async(mp_helper, args=(query.strip(), args), callback=mp_callback) - #mp_callback( mp_helper(query.strip(), args) ) + for query in get_smiles_or_smarts( args ): + pool.apply_async(mp_helper, args=(query, args), callback=mp_callback) + #mp_callback( mp_helper(query, args) ) pool.close() pool.join() diff -r 9d1f982555ba -r 12822efbd4a4 subsearch/subsearch.xml --- a/subsearch/subsearch.xml Fri Apr 26 11:05:19 2013 -0400 +++ b/subsearch/subsearch.xml Sat May 11 17:11:45 2013 -0400 @@ -7,6 +7,7 @@ subsearch.py -i $query + --iformat "${query.ext}" --fastsearch-index "${os.path.join($fastsearch.extra_files_path,'molecule.fs')}" -o "${outfile}" --oformat $oformat @@ -45,7 +46,7 @@ **What it does** -Substructure search in a Open Babel Fastsearch Index. You can search with SMILES or SMARTS pattern. +Substructure search in a Open Babel Fastsearch Index. You can search with SMILES or SMARTS pattern, SD- and InChI files will be converted to SMILES. -----