annotate qpcr_search.py @ 0:1f4836da4a14 draft default tip

planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
author bvalot
date Tue, 14 Jun 2022 08:52:22 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
1 #!/usr/bin/env python3
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
2 # -*- coding: utf-8 -*-
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
3
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
4 """Search primers/probe on database and return result"""
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
5
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
6 import argparse
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
7 import os
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
8 import subprocess
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
9 import sys
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
10 import tempfile
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
11
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
12 from Bio import SeqIO
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
13
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
14 gasst_exe = "Gassst"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
15 nucleo = {
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
16 "R": ("A", "G"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
17 "Y": ("C", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
18 "S": ("G", "C"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
19 "W": ("A", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
20 "K": ("G", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
21 "M": ("A", "C"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
22 "B": ("C", "G", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
23 "D": ("A", "G", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
24 "H": ("A", "C", "T"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
25 "V": ("A", "C", "G"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
26 "N": ("A", "T", "C", "G"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
27 }
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
28
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
29 desc = "Search primer/probe on database and return position and errors."
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
30 command = argparse.ArgumentParser(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
31 prog="primer_search.py",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
32 description=desc,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
33 usage="%(prog)s [options] forward probe reverse database",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
34 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
35 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
36 "-o",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
37 "--out",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
38 nargs="?",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
39 type=argparse.FileType("w"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
40 default=sys.stdout,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
41 help="Return amplicon position on file, default=stdout",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
42 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
43 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
44 "-d",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
45 "--debug",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
46 nargs="?",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
47 type=argparse.FileType("w"),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
48 default=None,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
49 help="Conserve a copy of primer search, default No",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
50 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
51 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
52 "-e",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
53 "--error",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
54 nargs="?",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
55 type=int,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
56 default=1,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
57 help="Maximun error allowed on match, default=1",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
58 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
59 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
60 "-m",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
61 "--min",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
62 nargs="?",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
63 type=int,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
64 default=50,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
65 help="Min len amplicon size, default=50",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
66 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
67 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
68 "-M",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
69 "--max",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
70 nargs="?",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
71 type=int,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
72 default=200,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
73 help="Max len amplicon size, default=200",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
74 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
75 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
76 "-t", "--taxo", action="store_true", help="Parse description to report species only"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
77 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
78 command.add_argument("forward", type=str, help="Forward primer sequence")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
79 command.add_argument("probe", type=str, help="Probe sequence")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
80 command.add_argument("reverse", type=str, help="Reverse primer sequence")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
81 command.add_argument(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
82 "database", type=argparse.FileType("r"), help="Database to search on fasta"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
83 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
84 command.add_argument("-v", "--version", action="version", version="%(prog)s 0.3.0")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
85
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
86
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
87 class GassstResult:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
88 """A simple Gassst class containing result
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
89 rev : True indicate if reverse primers, else forward
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
90 """
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
91
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
92 def __init__(self, line):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
93 h = line.strip().split()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
94 if len(h) != 9:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
95 raise Exception("Line seems not correspond to gassst result\n" + line)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
96 self.primer = h[0]
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
97 # self.rev = h[0] != "Forward"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
98 self.match = h[1]
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
99 self.strand = int(h[2])
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
100 self.start = int(h[3])
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
101 self.error = int(h[5])
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
102 self.stop = self.start + len(h[7])
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
103
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
104 def __repr__(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
105 return (
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
106 self.match
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
107 + " : "
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
108 + str(self.start)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
109 + " in strand:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
110 + str(self.strand)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
111 + " in primer: "
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
112 + self.primer
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
113 + " with error: "
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
114 + str(self.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
115 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
116
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
117 def __eq__(self, other):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
118 return (
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
119 isinstance(other, GassstResult)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
120 and self.primer == other.primer
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
121 and self.match == other.match
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
122 and self.strand == other.strand
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
123 and self.start == other.start
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
124 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
125
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
126 def __ne__(self, other):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
127 return not self == other
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
128
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
129 def __lt__(self, other):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
130 if self != other:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
131 raise Exception("Only compare equal GassstResult")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
132 return self.error < other.error
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
133
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
134
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
135 class Amplicon:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
136 """A simple Amplicon class containing forward and reverse gassst result
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
137 Add probe including
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
138 """
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
139
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
140 def __init__(self, forw, reve):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
141 if forw.strand == reve.strand:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
142 raise Exception(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
143 "Amplicon could be in inverse strand for reverse/forward primer\n"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
144 + forw
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
145 + reve
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
146 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
147 self.forw = forw
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
148 self.prob = None
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
149 self.reve = reve
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
150 self.strand = forw.strand
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
151
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
152 def contain_probe(self, probe):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
153 if (
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
154 min(probe.start, probe.stop) > self.get_start()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
155 and max(probe.start, probe.stop) < self.get_stop()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
156 ):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
157 self.prob = probe
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
158 return True
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
159 return False
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
160
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
161 def get_start(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
162 if self.strand == 0:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
163 return self.forw.start
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
164 return self.reve.start
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
165
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
166 def get_stop(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
167 if self.strand == 1:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
168 return self.forw.stop
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
169 return self.reve.stop
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
170
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
171 def get_tab_data(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
172 return map(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
173 str,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
174 [
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
175 self.get_start(),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
176 self.get_stop(),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
177 self.forw.error,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
178 self.prob.error,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
179 self.reve.error,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
180 ],
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
181 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
182
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
183 def __len__(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
184 return self.get_stop() - self.get_start()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
185
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
186 def __repr__(self):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
187 if self.prob is None:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
188 return (
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
189 str(self.get_start())
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
190 + " : "
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
191 + str(self.get_stop())
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
192 + " in strand:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
193 + str(self.strand)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
194 + "; error F:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
195 + str(self.forw.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
196 + ",R:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
197 + str(self.reve.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
198 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
199 return (
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
200 str(self.get_start())
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
201 + " : "
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
202 + str(self.get_stop())
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
203 + " in strand:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
204 + str(self.strand)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
205 + "; error F:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
206 + str(self.forw.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
207 + ",P:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
208 + str(self.prob.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
209 + ",R:"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
210 + str(self.reve.error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
211 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
212
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
213
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
214 def degenerate_primer(seq):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
215 """Iterate all possible sequence
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
216 from degenerate primer
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
217 """
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
218 notdegene = True
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
219 for i, n in enumerate(seq.upper()):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
220 if n in nucleo:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
221 notdegene = False
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
222 for mod in nucleo.get(n):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
223 seq_cut = list(seq)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
224 seq_cut[i] = mod
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
225 for seq2 in degenerate_primer("".join(seq_cut)):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
226 yield (seq2)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
227 break
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
228 if notdegene:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
229 yield (seq)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
230
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
231
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
232 def write_primer_fasta(forward_de, probe_de, reverse_de):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
233 primer_fasta = tempfile.NamedTemporaryFile(delete=False, mode="w+t")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
234 for forward in degenerate_primer(forward_de):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
235 primer_fasta.write(">Forward\n" + forward + "\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
236 for probe in degenerate_primer(probe_de):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
237 primer_fasta.write(">Probe\n" + probe + "\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
238 for reverse in degenerate_primer(reverse_de):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
239 primer_fasta.write(">Reverse\n" + reverse + "\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
240 primer_fasta.close()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
241 return primer_fasta.name
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
242
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
243
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
244 def performed_gassst(command):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
245 proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=sys.stderr)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
246 error = ""
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
247 for line in iter(proc.stderr.readline, b""):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
248 error += line.decode()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
249 if error != "":
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
250 sys.stdout.write("Error during processing Gassst\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
251 raise Exception(error)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
252
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
253
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
254 def read_result(f_res, f_debug):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
255 result = {}
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
256 for line in iter(f_res.readline, ""):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
257 if line[0] == "F" or line[0] == "R" or line[0] == "P":
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
258 if f_debug is not None:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
259 f_debug.write(line)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
260 res = GassstResult(line)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
261 other_res = result.setdefault(res.match, {}).setdefault(res.primer, [])
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
262 notfound = True
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
263 for i, res2 in enumerate(other_res):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
264 if res == res2:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
265 notfound = False
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
266 if res < res2:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
267 other_res[i] = res
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
268 # print res
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
269 break
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
270 if notfound:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
271 other_res.append(res)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
272 return result
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
273
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
274
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
275 def get_amplicons(result):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
276 """Function to get amplicon on a sequence from forward / reverse result"""
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
277 for forw in result["Forward"]:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
278 for reve in result["Reverse"]:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
279 if forw.strand != reve.strand:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
280 amp = Amplicon(forw, reve)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
281 if amp.get_start() < amp.get_stop(): # must be side by side
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
282 for probe in result["Probe"]:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
283 if amp.contain_probe(probe):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
284 yield amp
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
285 break
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
286 del amp
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
287 else:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
288 del amp
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
289
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
290
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
291 if __name__ == "__main__":
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
292 """Performed job on execution script"""
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
293 args = command.parse_args()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
294 primer_fasta = write_primer_fasta(args.forward, args.probe, args.reverse)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
295 output_result = tempfile.NamedTemporaryFile(delete=False, mode="w+")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
296 identity = int(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
297 100 - args.error / float(max(len(args.forward), len(args.reverse))) * 100
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
298 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
299
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
300 command = [
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
301 gasst_exe,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
302 "-p",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
303 str(identity),
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
304 "-g",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
305 "0",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
306 "-w",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
307 "6",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
308 "-h",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
309 "0",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
310 "-i",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
311 primer_fasta,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
312 "-d",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
313 args.database.name,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
314 "-o",
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
315 output_result.name,
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
316 ]
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
317 performed_gassst(command)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
318 result = read_result(output_result, args.debug)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
319
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
320 # load amplicons
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
321 sys.stderr.write("Search amplicons : ")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
322 amplicons = {}
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
323 for seq in result.keys():
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
324 if len(result[seq]) == 3:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
325 # print "Search amplicon on seq: " + seq
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
326 for amplicon in get_amplicons(result[seq]):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
327 if len(amplicon) > args.min and len(amplicon) < args.max:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
328 amplicons.setdefault(seq, []).append(amplicon)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
329 else:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
330 del amplicon
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
331 # print "Find amplicons : " + str(len(amplicons[seq]))
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
332 sys.stderr.write(str(sum(map(len, amplicons.values()))) + "\n\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
333
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
334 # print amplicons
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
335
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
336 sys.stderr.write("Write result : ")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
337 sep = "\t"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
338 args.out.write(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
339 "Id\tAmpli number\tDescription\tStart\tStop\tError forward\tError probe\tError reverse\n"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
340 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
341 for record in SeqIO.parse(args.database, "fasta"):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
342 if record.id not in amplicons:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
343 continue
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
344 for i, amplicon in enumerate(amplicons.get(record.id)):
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
345 desc = record.description.lstrip(record.id)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
346 if args.taxo:
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
347 desc = record.description.split(";")[-1].strip()
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
348 args.out.write(
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
349 record.id
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
350 + sep
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
351 + str(i + 1)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
352 + sep
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
353 + desc
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
354 + sep
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
355 + sep.join(amplicon.get_tab_data())
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
356 + "\n"
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
357 )
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
358 sys.stderr.write("OK\n")
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
359 # delete tempfile
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
360 os.unlink(primer_fasta)
1f4836da4a14 planemo upload for repository https://github.com/bvalot/galaxy commit d57c24d4b2c0c741d572af9ca0d09f8b82689640
bvalot
parents:
diff changeset
361 os.unlink(output_result.name)