Mercurial > repos > saketkc > mutation_assessor
changeset 3:f556d221daa2 draft
Uploaded
author | saketkc |
---|---|
date | Mon, 14 Apr 2014 14:01:35 -0400 |
parents | eae0427d25d6 |
children | 9239a3319e64 |
files | mutationassesor_web/README.rst mutationassesor_web/mutation_assesor.py mutationassesor_web/mutation_assesor.xml mutationassesor_web/tool_dependencies.xml tools/mutationassesor_web/README.rst tools/mutationassesor_web/mutation_assesor.py tools/mutationassesor_web/mutation_assesor.xml tools/mutationassesor_web/tool_dependencies.xml |
diffstat | 8 files changed, 194 insertions(+), 170 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mutationassesor_web/README.rst Mon Apr 14 14:01:35 2014 -0400 @@ -0,0 +1,36 @@ +Galaxy wrapper for the Mutation Assessor webservice +=================================================== + +This tool is copyright 2014 by Saket Choudhary<saketkc@gmail.com>, Indian Institute of Technology Bombay +All rights reserved. MIT licensed. + +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. + +Citations +=========== + + +If you use this Galaxy tool in work leading to a scientific publication please cite: + +Reva B, Antipin Y, Sander C. Nucleic Acids Research (2011) "Predicting the Functional Impact of Protein Mutations: Application to Cancer Genomics" + +Reva, B.A., Antipin, Y.A. and Sander, C. (2007) Genome Biol, 8, R232. "Determinants of protein function revealed by combinatorial entropy optimization"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mutationassesor_web/mutation_assesor.py Mon Apr 14 14:01:35 2014 -0400 @@ -0,0 +1,64 @@ +#!/usr/bin/env python +import sys +import requests +import os +import argparse +import re + +__url__ = 'http://mutationassessor.org/' + + +def stop_err(msg, err=1): + sys.stderr.write('%s\n' % msg) + sys.exit(err) + + +def main_web(args): + assert os.path.exists(args.input) + with open(args.input) as f: + contents = f.read().strip() + if args.hg19 is True and args.protein is True: + stop_err('--hg19 option conflicts with --protein') + if args.protein is False: + ## Replace tabs/space with commas + re.sub('[\t\s]+', ',', contents) + if args.hg19: + ## Append hg19 to each line + lines = contents.split('\n') + contents = ('\n').join( + map((lambda x: 'hg19,' + x), + lines)) + + payload = {'vars': contents, 'tableQ': 1} + request = requests.post(__url__, data=payload) + response = request.text + if request.status_code != requests.codes.ok: + stop_err("""Error retrieving response from server. + Server returned %s . + Output: %s + """ % (request.status_code, response)) + with open(args.output, 'wb') as fp: + fp.write(response) + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description="Process input output paths") + parser.add_argument('--input', + type=str, + required=True, + help='Input file location') + parser.add_argument('--output', + type=str, + required=True, + help='Output file locatio') + parser.add_argument('--log', + type=str, + required=False) + parser.add_argument('--hg19', + action='store_true', + help="""Use hg19 build. + Appends 'hg19' to each input line""") + parser.add_argument('--protein', + action='store_true', + help='Inputs are in protein space') + args = parser.parse_args() + main_web(args)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mutationassesor_web/mutation_assesor.xml Mon Apr 14 14:01:35 2014 -0400 @@ -0,0 +1,88 @@ +<tool id="mutationassesor_web" name="MutationAssesor"> + <description>MutationAssesor web service</description> + <requirements> + <requirement type="python-module">requests</requirement> + </requirements> + <command interpreter="python">mutation_assesor.py --input $input --output $output + #if $options.protein == "yes" + --protein + #else + $options.hg19 + #end if + </command> + <inputs> + <param name="input" format="txt" type="data" label="Input variants" /> + <conditional name="options"> + <param name="protein" type="select" label="Protein Input"> + <option value="yes">Yes</option> + <option value="no">No</option> + </param> + <when value="no"> + <param name="hg19" type="select" label="hg19"> + <option value="--hg19">Yes</option> + <option value="">No</option> + </param> + </when> + </conditional> + </inputs> + <outputs> + <data name="output" format="csv"/> + </outputs> + <help> + + + **What it does** + + This script calls MutationAssesor(http://mutationassessor.org/) Web API to fetch + Mutation Assesor scores and associated output. + + Input is a tab separated or comma separated varaibles file. MutationAssesor + server accepts list of variants, one variant per line, plus optional text thrown in + which might be a description of the variants in genomic coordinates. The + variants are assumed to be coming from '+' strand: + <genome build>,<chromosome>,<position>,<reference allele>,<substituted allele> + + + Genome build is optional. By default 'hg18' build is used. + Input needs to be formatted in the following format: + + 1. Nucleotide space: + + 13,32912555,G,T BRCA2 + + 7,55178574,G,A GBM + + 7,55178574,G,A GBM + + Note that the tool takes care of prepending 'hg19' while running the tool, if you + select 'yes' under 'hg19' label + + 2. Protein Space + <protein ID> <variant> <text>, where <protein ID> can be : + + 1. Uniprot protein accession (i.e. EGFR_HUMAN) + 2. NCBI Refseq protein ID (i.e. NP_005219) + + EGFR_HUMAN R521K + EGFR_HUMAN R98Q Polymorphism + EGFR_HUMAN G719D disease + NP_000537 G356A + NP_000537 G360A dbSNP:rs35993958 + NP_000537 S46A Abolishes phosphorylation + + + + **Citations** + + If you use this tool in Galaxy, please cite : + Reva B, Antipin Y, Sander C. Nucleic Acids Research (2011) + "Predicting the Functional Impact of Protein Mutations: Application to Cancer Genomics" + + Reva, B.A., Antipin, Y.A. and Sander, C. (2007) Genome Biol, 8, R232. + "Determinants of protein function revealed by combinatorial entropy optimization" + + + + </help> +</tool> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mutationassesor_web/tool_dependencies.xml Mon Apr 14 14:01:35 2014 -0400 @@ -0,0 +1,6 @@ +<?xml version="1.0"?> +<tool_dependency> + <package name="requests" version="2.2.1"> + <repository changeset_revision="570c2648d96d" name="package_requests_2_2_1" owner="saketkc" toolshed="http://testtoolshed.g2.bx.psu.edu" /> + </package> +</tool_dependency>
--- a/tools/mutationassesor_web/README.rst Wed Nov 20 01:55:00 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -Galaxy wrapper for the Mutation Assessor webservice -=================================================== - -This tool is copyright 2013 by Saket Choudhary, Indian Institute of Technology Bombay -All rights reserved. MIT licensed. - -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. - -Citations -=========== - - -If you use this Galaxy tool in work leading to a scientific publication please cite: - -Reva B, Antipin Y, Sander C. Nucleic Acids Research (2011) "Predicting the Functional Impact of Protein Mutations: Application to Cancer Genomics"
--- a/tools/mutationassesor_web/mutation_assesor.py Wed Nov 20 01:55:00 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -import sys -sys.path.insert(0, '/home/saket/requests-new-urllib3-api/requests/packages/') -sys.path.insert(0, '/home/saket/requests-new-urllib3-api') - - -import requests -from functools import wraps -import tempfile, shutil,time -import os,csv -#__url__="http://mutationassessor.org/?cm=var&var=%s&frm=txt&fts=all" -__url__="http://mutationassessor.org" -def stop_err( msg ): - sys.stderr.write( '%s\n' % msg ) - sys.exit() - -def retry(ExceptionToCheck, tries=4, delay=3, backoff=2, logger=None): - - """Retry calling the decorated function using an exponential backoff. - - http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ - original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry - - :param ExceptionToCheck: the exception to check. may be a tuple of - exceptions to check - :type ExceptionToCheck: Exception or tuple - :param tries: number of times to try (not retry) before giving up - :type tries: int - :param delay: initial delay between retries in seconds - :type delay: int - :param backoff: backoff multiplier e.g. value of 2 will double the delay - each retry - :type backoff: int - :param logger: logger to use. If None, print - :type logger: logging.Logger instance - """ - def deco_retry(f): - - @wraps(f) - - def f_retry(*args, **kwargs): - mtries, mdelay = tries, delay - while mtries > 1: - try: - return f(*args, **kwargs) - except ExceptionToCheck, e: - #msg = "%s, Retrying in %d seconds..." % (str(e), mdelay) - msg = "Retrying in %d seconds..." % (mdelay) - if logger: - logger.warning(msg) - else: - #print msg - pass - time.sleep(mdelay) - mtries -= 1 - mdelay *= backoff - return f(*args, **kwargs) - - return f_retry # true decorator - - return deco_retry -def main(params): - with open(params[0],"r") as f: - for i,sequence in enumerate(f): - #print sequence - sequence=sequence.replace("\t",",").replace(" ",",") - call=requests.get((__url__)%(sequence)) - with open(params[1],"a") as w: - text = call.content.replace("\\t","\t") - if i>1: - text_split=text.split("\n") - text="\t".join(text_split[1]) - w.write(text) - time.sleep(1) - return True - -def main_web(params): - tmp_dir = tempfile.mkdtemp() - path = os.path.join(tmp_dir,"csv_file") - in_txt = csv.reader(open(params[0],"rb"), delimiter="\t") - with open(path,"wb") as fp: - out_csv = csv.writer(fp,delimiter=",") - out_csv.writerows(in_txt) - fh = open(path,"rb") - readfile=fh.read() - fh.close() - payload = {"vars":readfile,"tableQ":"","protres":""} - request = requests.post(__url__,data=payload) - response = request.text - temp_file = os.path.join(tmp_dir,"int_file") - with open(temp_file,"wb") as w: - w.write(response) - - in_txt = csv.reader(open(temp_file,"rb"), delimiter=",") - with open(params[1],"wb") as fp: - out_csv = csv.writer(fp,delimiter="\t") - out_csv.writerows(in_txt) - shutil.rmtree(tmp_dir) - return True -if __name__=="__main__": - main_web(sys.argv[1:])
--- a/tools/mutationassesor_web/mutation_assesor.xml Wed Nov 20 01:55:00 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -<tool id="mutationassesor_web" name="MutationAssesor"> - <requirements> - <requirement type="package" version="2.0.1">requests</requirement> - </requirements> - <description>MutationAssesor web service</description> - <command interpreter="python"> - mutation_assesor.py $input $output - </command> - <inputs> - <param name="input" format="txt" type="data" label="Input variants" /> - </inputs> - <outputs> - <data name="output" format="tabular"/> - </outputs> - <help> - - **What it does** - - The server predicts the functional impact of amino-acid substitutions in proteins, such as mutations discovered - in cancer or missense polymorphisms. The functional impact is assessed based on evolutionary conservation of - the affected amino acid in protein homologs. - The method has been validated on a large set (60k) of disease associated (OMIM) and polymorphic variants - - **Citation** - If you use this Galaxy tool in work leading to a scientific publication please cite: - Reva B, Antipin Y, Sander C. Nucleic Acids Research (2011) "Predicting the Functional Impact of Protein Mutations: Application to Cancer Genomics" - </help> -</tool> -
--- a/tools/mutationassesor_web/tool_dependencies.xml Wed Nov 20 01:55:00 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<tool_dependency> - <package name="requests" version="2.0.1"> - <repository toolshed="http://testtoolshed.g2.bx.psu.edu" name="package_requests_2_0" owner="saketkc"/> - </package> -</tool_dependency> -