# HG changeset patch # User peterjc # Date 1486117954 18000 # Node ID 812383b5d3b8e9e51b0faf28c9e6ec80fe21df7a # Parent 5b552b3005f261de219f0a44c2ddc760d00fd3d0 v0.0.5 - galaxy_sequence_utils dependency and other cleanups inc using MIT license diff -r 5b552b3005f2 -r 812383b5d3b8 test-data/blastp_four_human_vs_rhodopsin.tabular --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/blastp_four_human_vs_rhodopsin.tabular Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,6 @@ +sp|P08100|OPSD_HUMAN gi|57163783|ref|NP_001009242.1| 96.55 348 12 0 1 348 1 348 0.0 701 +sp|P08100|OPSD_HUMAN gi|3024260|sp|P56514.1|OPSD_BUFBU 84.80 342 51 1 1 341 1 342 0.0 619 +sp|P08100|OPSD_HUMAN gi|283855846|gb|ADB45242.1| 94.82 328 17 0 11 338 1 328 0.0 653 +sp|P08100|OPSD_HUMAN gi|283855823|gb|ADB45229.1| 94.82 328 17 0 11 338 1 328 0.0 631 +sp|P08100|OPSD_HUMAN gi|223523|prf||0811197A 93.10 348 23 1 1 348 1 347 0.0 673 +sp|P08100|OPSD_HUMAN gi|12583665|dbj|BAB21486.1| 82.16 342 60 1 1 341 1 342 0.0 599 diff -r 5b552b3005f2 -r 812383b5d3b8 test-data/four_human_proteins.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/four_human_proteins.fasta Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,61 @@ +>sp|Q9BS26|ERP44_HUMAN Endoplasmic reticulum resident protein 44 OS=Homo sapiens GN=ERP44 PE=1 SV=1 +MHPAVFLSLPDLRCSLLLLVTWVFTPVTTEITSLDTENIDEILNNADVALVNFYADWCRF +SQMLHPIFEEASDVIKEEFPNENQVVFARVDCDQHSDIAQRYRISKYPTLKLFRNGMMMK +REYRGQRSVKALADYIRQQKSDPIQEIRDLAEITTLDRSKRNIIGYFEQKDSDNYRVFER +VANILHDDCAFL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YASVAFYIFTHQGSNFGPIFMTIPAFFAKSAAI +YNPVIYIMMNKQFRNCMLTTICCGKNPLGDDEASATVSKTETSQVAPA diff -r 5b552b3005f2 -r 812383b5d3b8 test-data/four_human_proteins_filter_a.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/four_human_proteins_filter_a.fasta Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,2 @@ +>sp|P08100|OPSD_HUMAN Rhodopsin OS=Homo sapiens GN=RHO PE=1 SV=1 +MNGTEGPNFYVPFSNATGVVRSPFEYPQYYLAEPWQFSMLAAYMFLLIVLGFPINFLTLYVTVQHKKLRTPLNYILLNLAVADLFMVLGGFTSTLYTSLHGYFVFGPTGCNLEGFFATLGGEIALWSLVVLAIERYVVVCKPMSNFRFGENHAIMGVAFTWVMALACAAPPLAGWSRYIPEGLQCSCGIDYYTLKPEVNNESFVIYMFVVHFTIPMIIIFFCYGQLVFTVKEAAAQQQESATTQKAEKEVTRMVIIMVIAFLICWVPYASVAFYIFTHQGSNFGPIFMTIPAFFAKSAAIYNPVIYIMMNKQFRNCMLTTICCGKNPLGDDEASATVSKTETSQVAPA diff -r 5b552b3005f2 -r 812383b5d3b8 test-data/four_human_proteins_filter_b.fasta --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test-data/four_human_proteins_filter_b.fasta Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,6 @@ +>sp|Q9BS26|ERP44_HUMAN Endoplasmic reticulum resident protein 44 OS=Homo sapiens GN=ERP44 PE=1 SV=1 +MHPAVFLSLPDLRCSLLLLVTWVFTPVTTEITSLDTENIDEILNNADVALVNFYADWCRFSQMLHPIFEEASDVIKEEFPNENQVVFARVDCDQHSDIAQRYRISKYPTLKLFRNGMMMKREYRGQRSVKALADYIRQQKSDPIQEIRDLAEITTLDRSKRNIIGYFEQKDSDNYRVFERVANILHDDCAFLSAFGDVSKPERYSGDNIIYKPPGHSAPDMVYLGAMTNFDVTYNWIQ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YLHNVVFVPRKTSSGTGAEDPRPSRKRRSLGDVGNVTVAVPTVAAFPNTSSTSVPTSPEEHRPFEKVVNKESLVISGLRHFTGYRIELQACNQDTPEERCSVAAYVSARTMPEAKADDIVGPVTHEIFENNVVHLMWQEPKEPNGLIVLYEVSYRRYGDEELHLCVSRKHFALERGCRLRGLSPGNYSVRIRATSLAGNGSWTEPTYFYVTDYLDVPSNIAKIIIGPLIFVFLFSVVIGSIYLFLRKRQPDGPLGPLYASSNPEYLSASDVFPCSVYVPDEWEVSREKITLLRELGQGSFGMVYEGNARDIIKGEAETRVAVKTVNESASLRERIEFLNEASVMKGFTCHHVVRLLGVVSKGQPTLVVMELMAHGDLKSYLRSLRPEAENNPGRPPPTLQEMIQMAAEIADGMAYLNAKKFVHRDLAARNCMVAHDFTVKIGDFGMTRDIYETDYYRKGGKGLLPVRWMAPESLKDGVFTTSSDMWSFGVVLWEITSLAEQPYQGLSNEQVLKFVMDGGYLDQPDNCPERVTDLMRMCWQFNPKMRPTFLEIVNLLKDDLHPSFPEVSFFHSEENKAPESEELEMEFEDMENVPLDRSSHCQREEAGGRDGGSSLGFKRSYEEHIPYTHMNGGKKNGRILTLPRSNPS diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_filter_by_id/README.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/fasta_filter_by_id/README.rst Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,114 @@ +Obsolete +======== + +This tool is now obsolete, having been replaced by a more general version +covering the FASTA, FASTQ and SFF sequence formats in a single tool. You +should only install this tool if you need to support existing workflows +which used it. + + +Galaxy tool to filter FASTA sequences by ID +=========================================== + +This tool is copyright 2010-2017 by Peter Cock, The James Hutton Institute +(formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. +See the licence text below (MIT licence). + +This tool is a short Python script (using the Galaxy library functions) which +divides a FASTA file in two, those sequences with or without an ID present in +the specified column(s) of a tabular file. Example uses include filtering based +on search results from a tool like NCBI BLAST, TMHMM or SignalP. + +There are just two files to install: + +* fasta_filter_by_id.py (the Python script) +* fasta_filter_by_id.xml (the Galaxy tool definition) + +The suggested location is next to the similarly named fasta_filter_by_length.py +and fasta_filter_by_length.xml files which are included with Galaxy, i.e. +in the Galaxy folder tools/fasta_tools + +You will also need to modify the tools_conf.xml file to tell Galaxy to offer +the tool. The suggested location is next to the fasta_filter_by_length.xml +entry. Simply add the line: + + + +That's it. + + +History +======= + +======= ====================================================================== +Version Changes +------- ---------------------------------------------------------------------- +v0.0.1 - Initial version (not publicly released) +v0.0.2 - Allow both, just pos or just neg output files +v0.0.3 - Include FASTA in tool name +v0.0.4 - Deprecated, marked as hidden in the XML +v0.0.5 - Explicit dependency on ``galaxy_sequence_utils``. + - Citation information (Cock et al. 2013). + - Explicitly record version via ````. + - Use standard MIT license (was previously using the MIT/BSD style + Biopython Licence Agreement). +======= ====================================================================== + + +Developers +========== + +This script and other tools for filtering FASTA, FASTQ and SFF files were +initially developed on the following hg branches: +http://bitbucket.org/peterjc/galaxy-central/src/tools +http://bitbucket.org/peterjc/galaxy-central/src/fasta_filter + +It is now under GitHub https://github.com/peterjc/pico_galaxy/ + +For pushing a release to the test or main "Galaxy Tool Shed", use the following +Planemo commands (which requires you have set your Tool Shed access details in +``~/.planemo.yml`` and that you have access rights on the Tool Shed):: + + $ planemo shed_update -t testtoolshed --check_diff tools/fasta_filter_by_id/ + ... + +or:: + + $ planemo shed_update -t toolshed --check_diff tools/fasta_filter_by_id/ + ... + +To just build and check the tar ball, use:: + + $ planemo shed_upload --tar_only tools/fasta_filter_by_id/ + ... + $ tar -tzf shed_upload.tar.gz + tools/fasta_filter_by_id/README.rst + tools/fasta_filter_by_id/fasta_filter_by_id.py + tools/fasta_filter_by_id/fasta_filter_by_id.xml + tools/fasta_filter_by_id/tool_dependencies.xml + test-data/four_human_proteins.fasta + test-data/blastp_four_human_vs_rhodopsin.tabular + test-data/four_human_proteins_filter_a.fasta + test-data/four_human_proteins_filter_b.fasta + + +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. diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_filter_by_id/fasta_filter_by_id.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/fasta_filter_by_id/fasta_filter_by_id.py Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,95 @@ +#!/usr/bin/env python +"""Filter a FASTA file with IDs from a tabular file, e.g. from BLAST. + +NOTE - This script is now OBSOLETE, having been replaced by a new verion +which handles FASTA, FASTQ and SFF all in one. + +Takes five command line options, tabular filename, ID column numbers +(comma separated list using one based counting), input FASTA filename, and +two output FASTA filenames (for records with and without the given IDs). + +If either output filename is just a minus sign, that file is not created. +This is intended to allow output for just the matched (or just the non-matched) +records. + +Note in the default NCBI BLAST+ tabular output, the query sequence ID is +in column one, and the ID of the match from the database is in column two. +Here sensible values for the column numbers would therefore be "1" or "2". + +This tool is copyright 2010-2017 by Peter Cock, The James Hutton Institute +(formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. +See accompanying text file for licence details (MIT license). +""" +import sys + +if "-v" in sys.argv or "--version" in sys.argv: + print "v0.0.5" + sys.exit(0) + +from galaxy_utils.sequence.fasta import fastaReader, fastaWriter + +# Parse Command Line +try: + tabular_file, cols_arg, in_file, out_positive_file, out_negative_file = sys.argv[1:] +except ValueError: + sys.exit("Expected five arguments, got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv))) +try: + columns = [int(arg)-1 for arg in cols_arg.split(",")] +except ValueError: + sys.exit("Expected list of columns (comma separated integers), got %s" % cols_arg) + +# Read tabular file and record all specified identifiers +ids = set() +handle = open(tabular_file, "rU") +if len(columns) > 1: + # General case of many columns + for line in handle: + if line.startswith("#"): + # Ignore comments + continue + parts = line.rstrip("\n").split("\t") + for col in columns: + ids.add(parts[col]) + print "Using %i IDs from %i columns of tabular file" % (len(ids), len(columns)) +else: + # Single column, special case speed up + col = columns[0] + for line in handle: + if not line.startswith("#"): + ids.add(line.rstrip("\n").split("\t")[col]) + print "Using %i IDs from tabular file" % (len(ids)) +handle.close() + +# Write filtered FASTA file based on IDs from tabular file +reader = fastaReader(open(in_file, "rU")) +if out_positive_file != "-" and out_negative_file != "-": + print "Generating two FASTA files" + positive_writer = fastaWriter(open(out_positive_file, "w")) + negative_writer = fastaWriter(open(out_negative_file, "w")) + for record in reader: + # The [1:] is because the fastaReader leaves the > on the identifer. + if record.identifier and record.identifier.split()[0][1:] in ids: + positive_writer.write(record) + else: + negative_writer.write(record) + positive_writer.close() + negative_writer.close() +elif out_positive_file != "-": + print "Generating matching FASTA file" + positive_writer = fastaWriter(open(out_positive_file, "w")) + for record in reader: + # The [1:] is because the fastaReader leaves the > on the identifer. + if record.identifier and record.identifier.split()[0][1:] in ids: + positive_writer.write(record) + positive_writer.close() +elif out_negative_file != "-": + print "Generating non-matching FASTA file" + negative_writer = fastaWriter(open(out_negative_file, "w")) + for record in reader: + # The [1:] is because the fastaReader leaves the > on the identifer. + if not record.identifier or record.identifier.split()[0][1:] not in ids: + negative_writer.write(record) + negative_writer.close() +else: + sys.exit("Neither output file requested") +reader.close() diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_filter_by_id/fasta_filter_by_id.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/fasta_filter_by_id/fasta_filter_by_id.xml Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,95 @@ + diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_filter_by_id/tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/fasta_filter_by_id/tool_dependencies.xml Fri Feb 03 05:32:34 2017 -0500 @@ -0,0 +1,6 @@ + + + + + + diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_tools/fasta_filter_by_id.py --- a/tools/fasta_tools/fasta_filter_by_id.py Tue Jun 07 17:23:07 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -#!/usr/bin/env python -"""Filter a FASTA file with IDs from a tabular file, e.g. from BLAST. - -Takes five command line options, tabular filename, ID column numbers -(comma separated list using one based counting), input FASTA filename, and -two output FASTA filenames (for records with and without the given IDs). - -If either output filename is just a minus sign, that file is not created. -This is intended to allow output for just the matched (or just the non-matched) -records. - -Note in the default NCBI BLAST+ tabular output, the query sequence ID is -in column one, and the ID of the match from the database is in column two. -Here sensible values for the column numbers would therefore be "1" or "2". - -This script is copyright 2010 by Peter Cock, SCRI, UK. All rights reserved. -See accompanying text file for licence details (MIT/BSD style). - -This is version 0.0.3 of the script. -""" -import sys -from galaxy_utils.sequence.fasta import fastaReader, fastaWriter - -def stop_err( msg ): - sys.stderr.write( msg ) - sys.exit() - -#Parse Command Line -try: - tabular_file, cols_arg, in_file, out_positive_file, out_negative_file = sys.argv[1:] -except ValueError: - stop_err("Expected five arguments, got %i:\n%s" % (len(sys.argv)-1, " ".join(sys.argv))) -try: - columns = [int(arg)-1 for arg in cols_arg.split(",")] -except ValueError: - stop_err("Expected list of columns (comma separated integers), got %s" % cols_arg) - -#Read tabular file and record all specified identifiers -ids = set() -handle = open(tabular_file, "rU") -if len(columns)>1: - #General case of many columns - for line in handle: - if line.startswith("#"): - #Ignore comments - continue - parts = line.rstrip("\n").split("\t") - for col in columns: - ids.add(parts[col]) - print "Using %i IDs from %i columns of tabular file" % (len(ids), len(columns)) -else: - #Single column, special case speed up - col = columns[0] - for line in handle: - if not line.startswith("#"): - ids.add(line.rstrip("\n").split("\t")[col]) - print "Using %i IDs from tabular file" % (len(ids)) -handle.close() - -#Write filtered FASTA file based on IDs from tabular file -reader = fastaReader(open(in_file, "rU")) -if out_positive_file != "-" and out_negative_file != "-": - print "Generating two FASTA files" - positive_writer = fastaWriter(open(out_positive_file, "w")) - negative_writer = fastaWriter(open(out_negative_file, "w")) - for record in reader: - #The [1:] is because the fastaReader leaves the > on the identifer. - if record.identifier and record.identifier.split()[0][1:] in ids: - positive_writer.write(record) - else: - negative_writer.write(record) - positive_writer.close() - negative_writer.close() -elif out_positive_file != "-": - print "Generating matching FASTA file" - positive_writer = fastaWriter(open(out_positive_file, "w")) - for record in reader: - #The [1:] is because the fastaReader leaves the > on the identifer. - if record.identifier and record.identifier.split()[0][1:] in ids: - positive_writer.write(record) - positive_writer.close() -elif out_negative_file != "-": - print "Generating non-matching FASTA file" - negative_writer = fastaWriter(open(out_negative_file, "w")) - for record in reader: - #The [1:] is because the fastaReader leaves the > on the identifer. - if not record.identifier or record.identifier.split()[0][1:] not in ids: - negative_writer.write(record) - negative_writer.close() -else: - stop_err("Neither output file requested") -reader.close() diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_tools/fasta_filter_by_id.txt --- a/tools/fasta_tools/fasta_filter_by_id.txt Tue Jun 07 17:23:07 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -Obsolete -======== - -This tool is now obsolete, having been replaced by a more general version -covering the FASTA, FASTQ and SFF sequence formats in a single tool. You -should only install this tool if you need to support existing workflows -which used it. - - -Galaxy tool to filter FASTA sequences by ID -=========================================== - -This tool is copyright 2010 by Peter Cock, SCRI, UK. All rights reserved. -See the licence text below. - -This tool is a short Python script (using the Galaxy library functions) which -divides a FASTA file in two, those sequences with or without an ID present in -the specified column(s) of a tabular file. Example uses include filtering based -on search results from a tool like NCBI BLAST, TMHMM or SignalP. - -There are just two files to install: - -* fasta_filter_by_id.py (the Python script) -* fasta_filter_by_id.xml (the Galaxy tool definition) - -The suggested location is next to the similarly named fasta_filter_by_length.py -and fasta_filter_by_length.xml files which are included with Galaxy, i.e. -in the Galaxy folder tools/fasta_tools - -You will also need to modify the tools_conf.xml file to tell Galaxy to offer -the tool. The suggested location is next to the fasta_filter_by_length.xml -entry. Simply add the line: - - - -That's it. - - -History -======= - -v0.0.1 - Initial version (not publicly released) -v0.0.2 - Allow both, just pos or just neg output files -v0.0.3 - Include FASTA in tool name -v0.0.4 - Deprecated, marked as hidden in the XML - - -Developers -========== - -This script and related tools are being developed on the following hg branch: -http://bitbucket.org/peterjc/galaxy-central/src/tools - -This incorporates the previously used hg branch: -http://bitbucket.org/peterjc/galaxy-central/src/fasta_filter - -For making the "Galaxy Tool Shed" http://community.g2.bx.psu.edu/ tarball use -the following command from the Galaxy root folder: - -tar -czf fasta_filter_by_id.tar.gz tools/fasta_tools/fasta_filter_by_id.* - -Check this worked: - -$ tar -tzf fasta_filter_by_id.tar.gz -fasta_tools/fasta_filter_by_id.py -fasta_tools/fasta_filter_by_id.txt -fasta_tools/fasta_filter_by_id.xml - - -Licence (MIT/BSD style) -======================= - -Permission to use, copy, modify, and distribute this software and its -documentation with or without modifications and for any purpose and -without fee is hereby granted, provided that any copyright notices -appear in all copies and that both those copyright notices and this -permission notice appear in supporting documentation, and that the -names of the contributors or copyright holders not be used in -advertising or publicity pertaining to distribution of the software -without specific prior permission. - -THE CONTRIBUTORS AND COPYRIGHT HOLDERS OF THIS SOFTWARE DISCLAIM ALL -WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT -OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE -OR PERFORMANCE OF THIS SOFTWARE. diff -r 5b552b3005f2 -r 812383b5d3b8 tools/fasta_tools/fasta_filter_by_id.xml --- a/tools/fasta_tools/fasta_filter_by_id.xml Tue Jun 07 17:23:07 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -