Mercurial > repos > artbio > mircounts
annotate yac.py @ 4:b7ac138bb781 draft default tip
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 51dc6c56c7d95fc229ffee958354211cd454fd36"
author | artbio |
---|---|
date | Sun, 09 May 2021 17:06:45 +0000 |
parents | ee99c6374a3b |
children |
rev | line source |
---|---|
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
1 #!/usr/bin/python |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
2 # yac = yet another clipper |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
3 # v 1.2.1 - 23-08-2014 - Support FastQ output |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
4 # v 1.1.0 - 23-08-2014 - argparse implementation |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
5 # Christophe Antoniewski <drosofff@gmail.com> |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
6 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
7 import argparse |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
8 from itertools import islice |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
9 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
10 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
11 def Parser(): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
12 the_parser = argparse.ArgumentParser() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
13 the_parser.add_argument( |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
14 '--input', action="store", nargs='+', help="input fastq files") |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
15 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
16 '--output', action="store", type=str, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
17 help="output, clipped fasta file") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
18 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
19 '--output_format', action="store", type=str, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
20 help="output format, fasta or fastq") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
21 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
22 '--adapter_to_clip', action="store", type=str, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
23 help="adapter sequence to clip") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
24 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
25 '--min', action="store", type=int, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
26 help="minimal size of clipped sequence to keep") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
27 the_parser.add_argument( |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
28 '--max', action="store", type=int, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
29 help="maximal size of clipped sequence to keep") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
30 the_parser.add_argument('--Nmode', action="store", type=str, choices=[ |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
31 "accept", "reject"], |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
32 help="accept or reject Ns in clipped sequences") |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
33 args = the_parser.parse_args() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
34 args.adapter_to_clip = args.adapter_to_clip.upper() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
35 return args |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
36 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
37 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
38 class Clip: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
39 |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
40 def __init__(self, inputfile, outputfile, output_format, |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
41 adapter, minsize, maxsize, Nmode): |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
42 self.inputfile = inputfile |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
43 self.outputfile = outputfile |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
44 self.output_format = output_format |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
45 self.adapter = adapter |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
46 self.minsize = int(minsize) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
47 self.maxsize = int(maxsize) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
48 self.Nmode = Nmode |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
49 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
50 def motives(sequence): |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
51 ''' |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
52 return a list of motives for perfect (6nt) or |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
53 imperfect (7nt with one mismatch) search on import string module |
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
54 ''' |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
55 sequencevariants = [ |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
56 sequence[0:6]] # initializes list with 6mer perfect match |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
57 dicsubst = {"A": "TGCN", "T": "AGCN", "G": "TACN", "C": "GATN"} |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
58 for pos in enumerate(sequence[:6]): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
59 for subst in dicsubst[pos[1]]: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
60 sequencevariants.append( |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
61 sequence[:pos[0]] + subst + sequence[pos[0] + 1:7]) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
62 return sequencevariants |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
63 self.adaptmotifs = motives(self.adapter) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
64 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
65 def scanadapt(self, adaptmotives=[], sequence="", qscore=""): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
66 '''scans sequence for adapter motives''' |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
67 match_position = sequence.rfind(adaptmotives[0]) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
68 if match_position != -1: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
69 return sequence[:match_position], qscore[:match_position] |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
70 for motif in adaptmotives[1:]: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
71 match_position = sequence.rfind(motif) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
72 if match_position != -1: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
73 return sequence[:match_position], qscore[:match_position] |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
74 return sequence, qscore |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
75 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
76 def write_output(self, id, read, qscore, output): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
77 if self.output_format == "fasta": |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
78 block = ">{0}\n{1}\n".format(id, read) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
79 else: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
80 block = "@HWI-{0}\n{1}\n+\n{2}\n".format(id, read, qscore) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
81 output.write(block) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
82 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
83 def handle_io(self): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
84 '''Open input file, pass read sequence and read qscore to clipping function. |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
85 Pass clipped read and qscore to output function.''' |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
86 id = 0 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
87 output = open(self.outputfile, "a") |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
88 with open(self.inputfile, "r") as input: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
89 block_gen = islice(input, 1, None, 2) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
90 for i, line in enumerate(block_gen): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
91 if i % 2: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
92 qscore = line.rstrip() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
93 else: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
94 read = line.rstrip() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
95 continue |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
96 trimmed_read, trimmed_qscore = self.scanadapt( |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
97 self.adaptmotifs, read, qscore) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
98 if self.minsize <= len(trimmed_read) <= self.maxsize: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
99 if (self.Nmode == "reject") and ("N" in trimmed_read): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
100 continue |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
101 id += 1 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
102 self.write_output(id, trimmed_read, trimmed_qscore, output) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
103 output.close() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
104 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
105 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
106 def main(*argv): |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
107 instanceClip = Clip(*argv) |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
108 instanceClip.handle_io() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
109 |
3
ee99c6374a3b
"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit af48e9f6df2717ffd3731a974be1ec36e4eff779"
artbio
parents:
0
diff
changeset
|
110 |
0
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
111 if __name__ == "__main__": |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
112 args = Parser() |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
113 id = 0 |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
114 for inputfile in args.input: |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
115 main(inputfile, args.output, args.output_format, |
10f0e4c00b13
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mircounts commit 3a6181bd181729f642b75c4e689f063fc2821cf1
artbio
parents:
diff
changeset
|
116 args.adapter_to_clip, args.min, args.max, args.Nmode) |