-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodon_retriever.pl
More file actions
68 lines (34 loc) · 1.41 KB
/
Codon_retriever.pl
File metadata and controls
68 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl -w
open(SEQFILE, "ScORFs.txt")||die "opening file $!";
@ORFarray = <SEQFILE>;
close (SEQFILE);
#this segment of code reads each line of the file, defining ORFs details, into an array
@NEWDATA=();
open (RESULTS, ">>results_file.txt") ||die "cannot open results.txt: $!";
@NEWDATA = <RESULTS>;
push (@NEWDATA, "frame-codon2.pl\n");
push (@NEWDATA, "Codons\n");
for($index=0; $index<@ORFarray; $index++){
$gene = $ORFarray [$index];
#this 'for' loop takes each line of sequence details in turn out of the array ready for processing
$findtext = index ($gene, ">" , 0);
# finds out where the letter Y is, defining the beginning of the Scer yeast name
$scername= substr ($gene,$findtext,8);
# extracts the Scer gene name
$ATGregion = index ($gene, "???", 0);
$ORFseq = substr ($gene, $ATGregion+3);
$genelen = length ($ORFseq) -2;
#measures length of gene sequence
print "$scername \t $genelen\n";
my $len = 3;
$gene = $ORFseq;
for (my $ORFcod = 1; $ORFcod <= length $ORFseq; $ORFcod += ($len)) {
$codon = substr ($ORFseq, $ORFcod - 1, $len);
my $sixnt = substr ($ORFseq, $ORFcod - 1, $len +3);
my $position = ($ORFcod + (length $sixnt) - 1);
push (@NEWDATA, "$codon\n");
}
}
print RESULTS @NEWDATA;
print (scalar(@NEWDATA)-scalar(@ORFarray));
close(RESULTS);