Mercurial > repos > artbio > small_rna_signatures
comparison overlapping_reads.py @ 13:124f404b0fe7 draft
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_signatures commit bc672cf9d5fe9c1f7eaf02abdc906cf2c1763668
author | artbio |
---|---|
date | Sat, 25 Feb 2023 09:54:28 +0000 |
parents | 8d3ca9652a5b |
children |
comparison
equal
deleted
inserted
replaced
12:aa5e2c64dff8 | 13:124f404b0fe7 |
---|---|
88 def countpairs(self, uppers, lowers): | 88 def countpairs(self, uppers, lowers): |
89 query_range = self.query_range | 89 query_range = self.query_range |
90 target_range = self.target_range | 90 target_range = self.target_range |
91 uppers = [seq for seq in uppers if (len(seq) in query_range or len(seq) | 91 uppers = [seq for seq in uppers if (len(seq) in query_range or len(seq) |
92 in target_range)] | 92 in target_range)] |
93 print(uppers) | |
94 uppers_expanded = [] | 93 uppers_expanded = [] |
95 for seq in uppers: | 94 for seq in uppers: |
96 expand = [seq for i in range(self.readdic[seq])] | 95 expand = [seq for i in range(self.readdic[seq])] |
97 uppers_expanded.extend(expand) | 96 uppers_expanded.extend(expand) |
98 print(uppers_expanded) | |
99 uppers = uppers_expanded | 97 uppers = uppers_expanded |
100 lowers = [seq for seq in lowers if (len(seq) in query_range or len(seq) | 98 lowers = [seq for seq in lowers if (len(seq) in query_range or len(seq) |
101 in target_range)] | 99 in target_range)] |
102 lowers_expanded = [] | 100 lowers_expanded = [] |
103 for seq in lowers: | 101 for seq in lowers: |
121 target_range = self.target_range | 119 target_range = self.target_range |
122 overlap = self.overlap | 120 overlap = self.overlap |
123 stringresult = [] | 121 stringresult = [] |
124 header_template = '>%s|coord=%s|strand %s|size=%s|nreads=%s\n%s\n' | 122 header_template = '>%s|coord=%s|strand %s|size=%s|nreads=%s\n%s\n' |
125 total_pairs = 0 | 123 total_pairs = 0 |
126 print('Chromosome\tNbre of pairs') | |
127 for chrom in sorted(self.chromosomes): | 124 for chrom in sorted(self.chromosomes): |
128 number_pairs = 0 | 125 number_pairs = 0 |
129 for pos in self.all_query_positions[chrom]: | 126 for pos in self.all_query_positions[chrom]: |
130 stringbuffer = [] | 127 stringbuffer = [] |
131 uppers = self.alignement_dic[chrom, pos, 'F'] | 128 uppers = self.alignement_dic[chrom, pos, 'F'] |
147 header_template % | 144 header_template % |
148 (chrom, pos+overlap-len(downread)+1, '-', | 145 (chrom, pos+overlap-len(downread)+1, '-', |
149 len(downread), self.readdic[downread], | 146 len(downread), self.readdic[downread], |
150 self.revcomp(downread))) | 147 self.revcomp(downread))) |
151 stringresult.extend(sorted(set(stringbuffer))) | 148 stringresult.extend(sorted(set(stringbuffer))) |
152 print('%s\t%s' % (chrom, number_pairs)) | |
153 print('Total nbre of pairs that can be simultaneously formed\t%s' | |
154 % total_pairs) | |
155 F.write(''.join(stringresult)) | 149 F.write(''.join(stringresult)) |
156 | 150 |
157 def revcomp(self, sequence): | 151 def revcomp(self, sequence): |
158 antidict = {"A": "T", "T": "A", "G": "C", "C": "G", "N": "N"} | 152 antidict = {"A": "T", "T": "A", "G": "C", "C": "G", "N": "N"} |
159 revseq = sequence[::-1] | 153 revseq = sequence[::-1] |