comparison glimmer_wo_icm.py @ 0:a4136c1534be draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/glimmer commit 37388949e348d221170659bbee547bf4ac67ef1a
author bgruening
date Tue, 28 Nov 2017 10:11:42 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4136c1534be
1 #!/usr/bin/env python
2 """
3 Input: DNA Fasta File
4 Output: Tabular
5 Return Tabular File with predicted ORF's
6 Bjoern Gruening
7 """
8 import os
9 import shutil
10 import subprocess
11 import sys
12 import tempfile
13
14 from glimmer2seq import glimmer2seq
15
16
17 def main():
18 genome_seq_file = sys.argv[1]
19 outfile_classic_glimmer = sys.argv[2]
20 outfile_ext_path = sys.argv[3]
21 oufile_genes = sys.argv[8]
22
23 tag = 'glimmer_non_knowlegde_based_prediction'
24 tempdir = tempfile.gettempdir()
25
26 trainingset = os.path.join(tempdir, tag + ".train")
27 icm = os.path.join(tempdir, tag + ".icm")
28
29 longorfs = tempfile.NamedTemporaryFile()
30 trainingset = tempfile.NamedTemporaryFile()
31 icm = tempfile.NamedTemporaryFile()
32
33 # glimmeropts = "-o0 -g110 -t30 -l"
34 glimmeropts = "-o%s -g%s -t%s" % (sys.argv[4], sys.argv[5], sys.argv[6])
35 if sys.argv[7] == "true":
36 glimmeropts += " -l"
37
38 """
39 1. Find long, non-overlapping orfs to use as a training set
40 """
41 subprocess.Popen(["long-orfs", "-n", "-t", "1.15",
42 genome_seq_file, "-"], stdout=longorfs,
43 stderr=subprocess.PIPE).communicate()
44
45 """
46 2. Extract the training sequences from the genome file
47 """
48 subprocess.Popen(["extract", "-t",
49 genome_seq_file, longorfs.name], stdout=trainingset,
50 stderr=subprocess.PIPE).communicate()
51
52 """
53 3. Build the icm from the training sequences
54 """
55
56 # the "-" parameter is used to redirect the output to stdout
57 subprocess.Popen(["build-icm", "-r", "-"],
58 stdin=open(trainingset.name), stdout=icm,
59 stderr=subprocess.PIPE).communicate()
60
61 """
62 Run Glimmer3
63 """
64 subprocess.Popen(["glimmer3", glimmeropts,
65 genome_seq_file, icm.name, os.path.join(tempdir, tag)],
66 stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
67
68 if outfile_classic_glimmer.strip() != 'None':
69 shutil.copyfile(os.path.join(tempdir, tag + ".predict"), outfile_classic_glimmer)
70 if outfile_ext_path.strip() != 'None':
71 shutil.copyfile(os.path.join(tempdir, tag + ".detail"), outfile_ext_path)
72
73 glimmer2seq(os.path.join(tempdir, tag + ".predict"), genome_seq_file, oufile_genes)
74
75
76 if __name__ == "__main__":
77 main()