annotate getLongestORF.py @ 0:c0f423210af0 draft default tip

planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
author mbernt
date Mon, 07 Aug 2023 13:52:15 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
1 #!/usr/bin/env python
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
2
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
3 #example:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
4 #>STRG.1.1(-)_1 [10 - 69]
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
5 #GGNHHTLGGKKTFSYTHPPC
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
6 #>STRG.1.1(-)_2 [3 - 80]
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
7 #FLRGEPPHIGGKKDIFLHPPTLLKGR
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
8
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
9 #output1: fasta file with all longest ORFs per transcript
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
10 #output2: table with information about seqID, transcript, start, end, strand, length, sense, longest? for all ORFs
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
11
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
12 import sys,re;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
13
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
14 def findlongestOrf(transcriptDict,old_seqID):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
15 #write for previous seqID
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
16 prevTranscript = transcriptDict[old_seqID];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
17 i_max = 0;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
18 transcript = old_seqID.split("(")[0]
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
19
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
20 #find longest orf in transcript
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
21 for i in range(0,len(prevTranscript)):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
22 if(prevTranscript[i][2] >= prevTranscript[i_max][2]):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
23 i_max = i;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
24
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
25 for i in range(0,len(prevTranscript)):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
26 prevORFstart = prevTranscript[i][0];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
27 prevORFend = prevTranscript[i][1];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
28 prevORFlength = prevTranscript[i][2];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
29 header = prevTranscript[i][3];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
30 strand = re.search('\(([+-]+)\)',header).group(1);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
31
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
32 output = str(header) + "\t" + str(transcript) + "\t" + str(prevORFstart) + "\t" + str(prevORFend) + "\t" + str(prevORFlength) + "\t" + str(strand);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
33 if (prevORFend - prevORFstart > 0):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
34 output+="\tnormal";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
35 else:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
36 output+="\treverse_sense";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
37 if(i == i_max):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
38 output += "\ty\n";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
39 else:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
40 output += "\tn\n";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
41
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
42 OUTPUT_ORF_SUMMARY.write(output);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
43
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
44 transcriptDict.pop(old_seqID, None);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
45 return None;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
46
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
47 #-----------------------------------------------------------------------------------------------------
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
48
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
49 INPUT = open(sys.argv[1],"r");
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
50 OUTPUT_FASTA = open(sys.argv[2],"w");
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
51 OUTPUT_ORF_SUMMARY = open(sys.argv[3],"w");
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
52
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
53 seqID = "";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
54 old_seqID = "";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
55 lengthDict = {};
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
56 seqDict = {};
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
57 headerDict = {};
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
58 transcriptDict = {};
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
59
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
60 skip = False;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
61
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
62 OUTPUT_ORF_SUMMARY.write("seqID\ttranscript\torf_start\torf_end\tlength\tstrand\tsense\tlongest\n");
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
63
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
64 for line in INPUT:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
65 line = line.strip();
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
66 if(re.match(">",line)): #header
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
67 header = line.split(">")[1].split(" ")[0]
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
68 seqID = "_".join(line.split(">")[1].split("_")[:-1])
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
69 ORFstart = int (re.search('\ \[(\d+)\ -', line).group(1));
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
70 ORFend = int (re.search('-\ (\d+)\]',line).group(1));
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
71 length = abs(ORFend - ORFstart);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
72
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
73 if(seqID not in transcriptDict and old_seqID != ""): #new transcript
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
74 findlongestOrf(transcriptDict,old_seqID);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
75
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
76 if seqID not in transcriptDict:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
77 transcriptDict[seqID] = [];
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
78
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
79 transcriptDict[seqID].append([ORFstart,ORFend,length,header]);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
80
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
81 if(seqID not in lengthDict and old_seqID != ""): #new transcript
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
82 #write FASTA
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
83 OUTPUT_FASTA.write(headerDict[old_seqID]+"\n"+seqDict[old_seqID]+"\n");
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
84 #delete old dict entry
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
85 headerDict.pop(old_seqID, None);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
86 seqDict.pop(old_seqID, None);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
87 lengthDict.pop(old_seqID, None);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
88 #if several longest sequences exist with the same length, the dictionary saves the last occuring.
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
89 if(seqID not in lengthDict or length >= lengthDict[seqID]):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
90 headerDict[seqID] = line;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
91 lengthDict[seqID] = length;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
92 seqDict[seqID] = "";
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
93 skip = False;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
94 else:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
95 skip = True;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
96 next;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
97 old_seqID = seqID;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
98 elif(skip):
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
99 next;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
100 else:
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
101 seqDict[seqID] += line;
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
102
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
103 OUTPUT_FASTA.write(headerDict[old_seqID]+"\n"+seqDict[old_seqID]);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
104 findlongestOrf(transcriptDict,old_seqID);
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
105
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
106 INPUT.close();
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
107 OUTPUT_FASTA.close();
c0f423210af0 planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/blob/master/tools/longorf/ commit 82ae2fa7e7a4a51f7583c6a95bdafc5f843c7c3b
mbernt
parents:
diff changeset
108 OUTPUT_ORF_SUMMARY.close();