annotate glimmer_wo_icm.py @ 2:3186204e3146 draft default tip

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