changeset 0:9259f2939357

add refeditor into galaxy toolshed
author superyuan <shuaiyuan.emory@gmail.com>
date Thu, 12 Jun 2014 04:56:10 -0400
parents
children 85bdf226b67b
files tool_conf.xml tools/refeditor/DiploidConstructor.py tools/refeditor/DiploidConstructor.xml tools/refeditor/MappingConverter.py tools/refeditor/MappingConverter.xml
diffstat 5 files changed, 202 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_conf.xml	Thu Jun 12 04:56:10 2014 -0400
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<toolbox>
+ <section name="Reference Editor" id="refeditor">
+    <tool file="refeditor/DiploidConstructor.xml" />
+    <tool file="refeditor/MappingConverter.xml" />
+  </section>
+</toolbox>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/refeditor/DiploidConstructor.py	Thu Jun 12 04:56:10 2014 -0400
@@ -0,0 +1,84 @@
+# Filename: DiploidConstructor.py
+# Author: Shuai Yuan
+# Version: 05/27/2012
+#
+# This script is a wrapper for DiploidConstructor
+#
+# DiploidConstructor is launched based on these inputs:
+#  -r		haploid reference genome file 
+#  -g		genotypes file
+#  -l		read length
+#  -d		maximal deletion in a read and mapped to alternative alleles [default=0]
+#  -s		sex of the individual [default="m"]
+#  -o		output diploid reference genome file 
+
+import sys
+import os
+import re
+import string
+import commands
+from tempfile import NamedTemporaryFile
+
+# This function is exceedingly useful, perhaps package for reuse?
+def getopts(argv):
+    opts = {}
+    while argv:
+	if argv[0][0] == '-':
+	    opts[argv[0]] = argv[1]
+	    argv = argv[2:]
+	else:
+	    argv = argv[1:]
+    return opts
+
+def main():
+    args = sys.argv[1:]
+
+    try:
+	opts = getopts(args)
+    except IndexError:
+	print "Usage:"
+	return 0
+
+    hg19 = opts.get("-r")
+    if hg19 == None:
+        print "No reference file specified."
+        return -1
+    
+    genotypes = opts.get("-g")
+    if genotypes == None:
+        print "No genotypes file specified."
+        return -2
+
+    length = opts.get("-l")
+    if length == None:
+        print "No read length specified."
+        return -3
+
+    indel = opts.get("-d")
+    if indel == None:
+        print "No max deletion specified."
+        return -4
+
+    gender = opts.get("-d")
+    if gender == None:
+        print "No gender specified."
+        return -5
+
+    outputfile = opts.get("-o")
+    if outputfile == None:
+        print "No output file specified."
+        return -6
+ 
+
+# All inputs have been specified at this point, now validate.
+	
+    #generate command
+    commandline = "DiploidConstructor -r %s -g %s -l %s -d %s -s %s -o %s " % (hg19, genotypes, length, indel, gender, outputfile)
+    #run 
+    errorcode, stdout = commands.getstatusoutput(commandline)
+    
+    #return error code
+    return errorcode
+
+if __name__ == "__main__":
+    main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/refeditor/DiploidConstructor.xml	Thu Jun 12 04:56:10 2014 -0400
@@ -0,0 +1,27 @@
+<tool id="DiploidConstructor1" name="Diploid Constructor" version="1.0.1">
+  <description>Constructs Diploid Reference Genome</description>
+  <command interpreter="python">DiploidConstructor.py
+        -r '$input'
+        -g '$genotypes'
+        -l '$length'
+	-d '$indel'
+	-s '$gender'
+	-o $out_file1
+  </command>
+  <inputs>
+    <param format="fasta" name="input" type="data" label="Haploid Reference Genome"/>
+    <param format="genotypes" name="genotypes" type="data" label="Genotypes"/>
+    <param format="txt" name="length" type="text" value="36" label="Length of the reads"/>
+    <param format="txt" name="indel" type="text" value="0" label="Max deletion on reference genome"/>
+    <param name="gender" type="select" label="Gender">
+        <option value="male">male</option>
+        <option value="female">female</option>
+    </param>
+
+  </inputs>
+  <outputs>
+    <data format="fasta" name="out_file1" metadata_source="input"/>
+  </outputs>
+  <help>
+</help>
+</tool>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/refeditor/MappingConverter.py	Thu Jun 12 04:56:10 2014 -0400
@@ -0,0 +1,66 @@
+# Filename: MappingConverter.py
+# Author: Shuai Yuan
+# Version: 05/27/2012
+#
+# This script is a wrapper for MappingConvertor
+#
+# MappingConvertor is launched based on these inputs:
+#  -i		input intermediate SAM file
+#  -m		dipmap file generated with diploid reference genome
+#  -o		output final SAM file
+
+import sys
+import os
+import re
+import string
+import commands
+from tempfile import NamedTemporaryFile
+
+# This function is exceedingly useful, perhaps package for reuse?
+def getopts(argv):
+    opts = {}
+    while argv:
+	if argv[0][0] == '-':
+	    opts[argv[0]] = argv[1]
+	    argv = argv[2:]
+	else:
+	    argv = argv[1:]
+    return opts
+
+def main():
+    args = sys.argv[1:]
+
+    try:
+	opts = getopts(args)
+    except IndexError:
+	print "Usage:"
+	return 0
+
+    hg19di = opts.get("-m")
+    if hg19di == None:
+        print "No dipmap file specified."
+        return -1
+    
+    samfile = opts.get("-i")
+    if samfile == None:
+        print "No SAM file specified."
+        return -2
+
+    outputfile = opts.get("-o")
+    if outputfile == None:
+        print "No output file specified."
+        return -6
+ 
+
+# All inputs have been specified at this point, now validate.
+	
+    #generate command
+    commandline = "MappingConvertor -i %s -m %s.dipmap -o %s " % (samfile, hg19di, outputfile)
+    #run
+    errorcode, stdout = commands.getstatusoutput(commandline)
+    
+    #return error code
+    return errorcode
+
+if __name__ == "__main__":
+    main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/refeditor/MappingConverter.xml	Thu Jun 12 04:56:10 2014 -0400
@@ -0,0 +1,18 @@
+<tool id="MappingConverter1" name="Mapping Converter" version="1.0.1">
+  <description>Converts intermediate SAM file to final SAM file</description>
+  <command interpreter="python">MappingConverter.py
+        -i '$input'
+        -m '$hg19di'
+	-o $out_file1
+  </command>
+  <inputs>
+    <param format="sam" name="input" type="data" label="Input SAM File"/>
+    <param format="fasta" name="hg19di" type="data" label="Dipolid Reference Genome"/>
+
+  </inputs>
+  <outputs>
+    <data format="sam" name="out_file1" metadata_source="input"/>
+  </outputs>
+  <help>
+</help>
+</tool>