changeset 3:65a71127f1fa draft

Uploaded
author saketkc
date Mon, 14 Apr 2014 21:20:43 -0400
parents 8cdb62d808dc
children 328c3e782d31
files condel_web/README.rst condel_web/condel_web.py condel_web/condel_web.xml condel_web/tool_dependencies.xml tools/condel/README.rst tools/condel/condel_web.py tools/condel/condel_web.xml tools/condel/tool_dependencies.xml
diffstat 8 files changed, 225 insertions(+), 221 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/condel_web/README.rst	Mon Apr 14 21:20:43 2014 -0400
@@ -0,0 +1,35 @@
+Galaxy wrapper for the Condel 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:
+
+Improving the Assessment of the Outcome of Nonsynonymous SNVs with a Consensus Deleteriousness Score, Condel (2011) Abel Gonzlez-Perez and Nuria Lopez-Bigas, 
+American Journal of Human Genetics 10.1016/j.ajhg.2011.03.004 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/condel_web/condel_web.py	Mon Apr 14 21:20:43 2014 -0400
@@ -0,0 +1,134 @@
+import sys
+import requests
+import pycurl
+import os
+from os.path import getsize
+import argparse
+import cStringIO
+from functools import wraps
+import tempfile
+import shutil
+import time
+
+__url__ = "http://bg.upf.edu/condel/taskService"
+
+
+def stop_err(msg):
+    sys.stderr.write('%s\n' % msg)
+    sys.exit()
+
+
+def retry(ExceptionToCheck, tries=10, 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
+
+
+class TransficUploader:
+
+    def __init__(self):
+
+        self.c = pycurl.Curl()
+        self.c.setopt(pycurl.URL, __url__)
+        self.c.setopt(pycurl.UPLOAD, 1)
+        self.c.setopt(pycurl.PROXY,
+                      os.env['http_proxy'])
+        #'http://saket.kumar:uzfmTjX9839.1314@netmon.iitb.ac.in:80/')
+        self.c.setopt(pycurl.HTTPHEADER, ['Expect:'])
+        self.c.setopt(pycurl.UPLOAD, 1)
+        self.c.setopt(pycurl.NOPROGRESS, 1)
+        self.c.setopt(pycurl.USERAGENT, "curl/7.27.0")
+        self.c.setopt(pycurl.SSL_VERIFYPEER, 1)
+        self.c.setopt(pycurl.CUSTOMREQUEST, "PUT")
+        self.c.setopt(pycurl.TCP_NODELAY, 1)
+        self.buf = cStringIO.StringIO()
+        self.c.setopt(self.c.WRITEFUNCTION, self.buf.write)
+
+    def upload_file(self, filepath):
+        f = open(filepath)
+        self.c.setopt(pycurl.INFILE, f)
+        self.c.setopt(pycurl.INFILESIZE, getsize(filepath))
+
+    def run(self):
+        self.c.perform()
+
+    def get_url(self):
+        return self.buf.getvalue().strip()
+
+    @retry(requests.exceptions.HTTPError)
+    def result_exists(self, url):
+        #url="http://www.cravat.us/results/%s/%s.zip" %(job_id,job_id)
+        download_request = requests.request("GET", url)
+        if download_request.status_code == 404 or download_request == 500:
+            raise requests.HTTPError()
+        else:
+            return url
+
+    @retry(requests.exceptions.HTTPError)
+    def download_result(self, url, outpath):
+        tmp_dir = tempfile.mkdtemp()
+        r = requests.get(url, stream=True)
+        if r.status_code == 500:
+            raise requests.HTTPError()
+        else:
+            path = os.path.join(tmp_dir, "results.csv")
+            with open(path, 'wb') as f:
+                for chunk in r.iter_content(128):
+                    f.write(chunk)
+        shutil.move(path, outpath)
+        shutil.rmtree(tmp_dir)
+
+
+def main(params):
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--input", type=str, required=True)
+    parser.add_argument("--output", type=str, required=True)
+    args = parser.parse_args(params)
+    uploader = TransficUploader()
+    uploader.upload_file(args.input)
+    uploader.run()
+    url = uploader.get_url()
+    url = uploader.result_exists(url)
+    uploader.download_result(url, args.output)
+
+
+if __name__ == "__main__":
+    main(sys.argv[1:])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/condel_web/condel_web.xml	Mon Apr 14 21:20:43 2014 -0400
@@ -0,0 +1,50 @@
+<tool id="condel_web" name="condel">
+    <description>Condel web service</description>
+    <requirements>
+        <requirement type="package" version="2.2.1">requests</requirement>
+        <requirement type="python-module">requests</requirement>
+    </requirements>
+    <command interpreter="python">
+        condel_web.py --input $input --output $output
+    </command>
+    <inputs>
+        <param name="input" format="text" type="data" label="Input Variants" />
+    </inputs>
+    <outputs>
+        <data name="output" format="tabular"/>
+    </outputs>
+    <tests>
+        <test>
+            <param name="input" value="condel_input.txt"/>
+            <output name="output" file="condel_output.txt"/>
+        </test>
+    </tests>
+    <help>
+        **What it does**
+
+        This script calls condel web api at  http://bg.upf.edu/condel/
+
+        Condel stands for CONsensus DELeteriousness score of non-synonymous single nucleotide variants (SNVs).
+        The idea behind it is to integrate the output of computational tools aimed at assessing the impact of non synonymous SNVs on protein function.
+        To do this, it computes a weighted average of the scores (WAS) of these tools : SIFT, Polyphen2, MAPP, LogR Pfam E-value
+        (implemented ad hoc following the instructions at Clifford RJ, Edmonson MN, Nguyen C, and Buetow KH (2004)
+        Large-scale analysis of non-synonymous coding region single nucleotide polymorphisms. Bioinformatics 20, 1006-1014) and MutationAssessor
+
+        **How does it work**
+
+        The scores of different methods are weighted using the complementary cumulative distributions produced by the five methods on a
+        dataset of approximately 20000 missense SNPs, both deleterious and neutral. The probability that a predicted deleterious mutation is not a
+        false positive of the method and the probability that a predicted neutral mutation is not a false negative are employed as weights.
+
+        **Citation**
+
+
+        If you use this tool please cite:
+
+
+        Improving the Assessment of the Outcome of Nonsynonymous SNVs with a Consensus Deleteriousness Score, Condel (2011) Abel González-Pérez and Nuria López-Bigas, American Journal of Human Genetics 10.1016/j.ajhg.2011.03.004
+
+
+    </help>
+</tool>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/condel_web/tool_dependencies.xml	Mon Apr 14 21:20:43 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/condel/README.rst	Wed Nov 20 01:55:44 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-Galaxy wrapper for the Codel 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:
-
-Improving the Assessment of the Outcome of Nonsynonymous SNVs with a Consensus Deleteriousness Score, 
-Condel (2011) Abel González-Pérez and Nuria López-Bigas, American Journal of Human Genetics 10.1016/j.ajhg.2011.03.004
-
--- a/tools/condel/condel_web.py	Wed Nov 20 01:55:44 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +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
-import pycurl
-import os
-from os.path import getsize
-import argparse
-import sys
-import cStringIO
-from functools import wraps
-import tempfile, shutil,time
-
-__url__="http://bg.upf.edu/condel/taskService"
-def stop_err( msg ):
-    sys.stderr.write( '%s\n' % msg )
-    sys.exit()
-
-def retry(ExceptionToCheck, tries=10, 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
-
-class TransficUploader:
-    def __init__(self):
-
-        self.c = pycurl.Curl()
-        self.c.setopt(pycurl.URL, __url__)
-        self.c.setopt(pycurl.UPLOAD, 1)
-        #c.setopt(pycurl.USERPWD, 'saket.kumar:whatsinaname.')
-        self.c.setopt(pycurl.PROXY, 'http://saket.kumar:whatsinaname.@netmon.iitb.ac.in:80/')
-        #c.setopt(pycurl.PROXYPORT, 80)
-        #c.setopt(pycurl.PROXYTYPE_HTTP,1)
-        #self.c.setopt(pycurl.VERBOSE, 1)
-        self.c.setopt(pycurl.HTTPHEADER, ['Expect:'])
-        #c.setopt(pycurl.HTTPPROXYTUNNEL, 1)
-        self.c.setopt(pycurl.UPLOAD, 1)
-        #c.perform()
-        self.c.setopt(pycurl.NOPROGRESS, 1);
-        #curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1L);
-        self.c.setopt(pycurl.USERAGENT, "curl/7.27.0");
-        #curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
-        #curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
-        self.c.setopt(pycurl.SSL_VERIFYPEER, 1);
-        self.c.setopt(pycurl.CUSTOMREQUEST, "PUT")
-        #curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
-        self.c.setopt(pycurl.TCP_NODELAY, 1);
-        self.buf = cStringIO.StringIO()
-        self.c.setopt(self.c.WRITEFUNCTION, self.buf.write)
-
-
-    def upload_file(self,filepath):
-        f = open(filepath)
-        self.c.setopt(pycurl.INFILE, f)
-        self.c.setopt(pycurl.INFILESIZE, getsize(filepath))
-
-    def run(self):
-        self.c.perform()
-
-    def get_url(self):
-        return self.buf.getvalue().strip()
-
-    @retry(requests.exceptions.HTTPError)
-    def result_exists(self,url ):
-        #url="http://www.cravat.us/results/%s/%s.zip" %(job_id,job_id)
-        download_request = requests.request("GET", url)
-        if download_request.status_code==404 or download_request==500:
-            raise requests.HTTPError()
-        else:
-            return url
-    @retry(requests.exceptions.HTTPError)
-    def download_result(self, url,outpath):
-        tmp_dir = tempfile.mkdtemp()
-        r = requests.get( url, stream=True )
-        if r.status_code == 500:
-            raise requests.HTTPError()
-        else:
-            path = os.path.join( tmp_dir,"results.csv")
-            with open(path, 'wb') as f:
-                for chunk in r.iter_content(128):
-                    f.write(chunk)
-        shutil.move(path,outpath)
-        shutil.rmtree(tmp_dir)
-
-
-
-def main(params):
-    parser = argparse.ArgumentParser()
-    parser.add_argument("--input",type=str,required=True)
-    parser.add_argument("--output",type=str,required=True)
-    args = parser.parse_args(params)
-    uploader = TransficUploader();
-    uploader.upload_file(args.input)
-    uploader.run()
-    url = uploader.get_url()
-    url = uploader.result_exists(url)
-    download = uploader.download_result(url,args.output)
-if __name__=="__main__":
-    main(sys.argv[1:])
--- a/tools/condel/condel_web.xml	Wed Nov 20 01:55:44 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-<tool id="condel_web" name="condel">
-    <requirements>
-            <requirement type="package" version="2.0.1">requests</requirement>
-    </requirements>
-    <description>Condel web service</description>
-    <command interpreter="python">
-        condel_web.py --input $input --output $output
-    </command>
-    <inputs>
-        <param name="input" format="text" type="data" label="Input Variants" />
-    </inputs>
-    <outputs>
-        <data name="output" format="tabular"/>
-    </outputs>
-    <help>
-        **What it does**
-        Condel stands for CONsensus DELeteriousness score of non-synonymous single nucleotide variants (SNVs).
-        The idea behind it is to integrate the output of computational tools aimed at assessing the impact of non synonymous
-        SNVs on protein function. To do this, it computes a weighted average of the scores (WAS) of these tools.
-        Condel was developed to integrate the outputs of five tools: SIFT, Polyphen2, MAPP, LogR Pfam E-value
-        (implemented ad hoc following the instructions at Clifford RJ, Edmonson MN, Nguyen C, and Buetow KH (2004)
-        Large-scale analysis of non-synonymous coding region single nucleotide polymorphisms. Bioinformatics 20, 1006-1014) and MutationAssessor
-
-
-        The scores of different methods are weighted using the complementary cumulative distributions produced by the five
-        methods on a dataset of approximately 20000 missense SNPs, both deleterious and neutral.
-        The probability that a predicted deleterious mutation is not a false positive of the method and the probability that a
-        predicted neutral mutation is not a false negative are employed as weights
-
-        **Citation**
-
-        If you use this Galaxy tool in work leading to a scientific publication please cite:
-
-        Improving the Assessment of the Outcome of Nonsynonymous SNVs with a Consensus Deleteriousness Score,
-        Condel (2011) Abel González-Pérez and Nuria López-Bigas, American Journal of Human Genetics 10.1016/j.ajhg.2011.03.004
-    </help>
-</tool>
-
--- a/tools/condel/tool_dependencies.xml	Wed Nov 20 01:55:44 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>
-