@@ -100,9 +100,9 @@ def main():
100
100
fasta_path = sys .argv [2 ]
101
101
output_path = sys .argv [3 ]
102
102
103
- # bed_path = "/home/shinoda/Desktop/Florida/annotation/A1BG_exons .bed"
104
- # fasta_path = "/home/shinoda/Desktop/Florida/annotation/A1BG_exons .bed.fa"
105
- # output_path = "/home/shinoda/Desktop/Florida/annotation/A1BG_possible_transcripts_refseq .fa"
103
+ # bed_path = "/home/shinoda/Desktop/Florida/annotation/MBNL1_TEST/MBNL3_exons_hg19_refseq .bed"
104
+ # fasta_path = "/home/shinoda/Desktop/Florida/annotation/MBNL1_TEST/MBNL3_exons_hg19_refseq .bed.fa"
105
+ # output_path = "/home/shinoda/Desktop/Florida/annotation/MBNL1_TEST/MBNL3_possible_transcripts_refseq_REVERSE .fa"
106
106
107
107
# exon_stop_coords = exon_stop.split("-")
108
108
@@ -114,6 +114,7 @@ def main():
114
114
for line in f :
115
115
tokens = line .rstrip ().split ("\t " )
116
116
chr = tokens [0 ]
117
+ strand = tokens [5 ]
117
118
# Save the cordinates in the list
118
119
if ([tokens [1 ],tokens [2 ]] not in exons_list ):
119
120
exons_list .append ([tokens [1 ],tokens [2 ]])
@@ -129,13 +130,22 @@ def main():
129
130
raise Exception ("Only 1 transcript associated to this gene. Stop execution." )
130
131
131
132
# Sort the list of exons
132
- exons_list_sorted = sorted (exons_list , key = lambda x : (x [1 ], x [0 ]))
133
- # # Get the position of the exon_stop in exons_list_sorted
133
+ # Depending on the strand, we have to sort it in a different way
134
+ if (strand == "+" ):
135
+ exons_list_sorted = sorted (exons_list , key = lambda x : (x [1 ], x [0 ]))
136
+ else :
137
+ exons_list_sorted = sorted (exons_list ,key = lambda x : (x [1 ], x [0 ]), reverse = True )
138
+
139
+ # Get the position of the exon_stop in exons_list_sorted
134
140
# exon_stop_coords_pos = exons_list_sorted.index(exon_stop_coords)
135
141
136
142
# Sort the exons associated to each transcript
137
143
for key , values in transcripts_dict .items ():
138
- transcripts_dict [key ] = sorted (values , key = lambda x : (x [1 ], x [0 ]))
144
+ if (strand == "+" ):
145
+ transcripts_dict [key ] = sorted (values , key = lambda x : (x [1 ], x [0 ]))
146
+ else :
147
+ transcripts_dict [key ] = sorted (values , key = lambda x : (x [1 ], x [0 ]), reverse = True )
148
+
139
149
# # Remove all the transcripts that doesn't include the exon_end
140
150
# # Copy the dictionary for iterating on it
141
151
# transcripts_dict_copy = deepcopy(transcripts_dict)
0 commit comments