-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.pl
More file actions
115 lines (94 loc) · 2.9 KB
/
tools.pl
File metadata and controls
115 lines (94 loc) · 2.9 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
sub freq(2){# intended paramters: freq(string string, string target)
my $relative_freq;
return $relative_freq;
}
###################################################################################
sub make_spliced(1){
my $spliced;
if(@_[0] eq 'exon'){
#print " in make exons";
foreach $exon(@exons){
#print $exon;
$spliced = $spliced . $exon;
}#exon for
}#exon if
elsif(@_[0] eq 'intron'){
#print "in make introns";
foreach $intron(@introns){
#print $intron;
$spliced = $spliced . $intron;
}#intron for
}#elsif
else {
print "Subroutine make_spliced passed bad input. \"exon\" for exonstring,";
print " \"intron\" for intron string. You passed: ";
print @_[0];
}
return $spliced;
}#sub routine
#################################################################################
sub exon_intron_init(){#creates the arrays of strings for introns and exons
@exons;
@introns;
for(my $c = 0; $c < scalar @estart; $c = $c + 1){
my $temp = substr($sequence, @estart[$c],@istart[$c]-@estart[$c]);
push(@exons,$temp); #fill @exon array with strings = each exon
}
for(my $c = 0; $c < scalar @istart - 1; $c = $c + 1){
my $temp = substr($sequence,@istart[$c],@estart[$c+1]-@istart[$c]);
push(@introns,$temp);
}
# foreach $string(@exons){
# print " exon size: "; print length($string);
# }
# print "\n\n";
# foreach $string(@introns){
# print " intron size: "; print length($string);
# }
# print "\n\n";
}
#################################################################################
sub file_test{#some testing prints for array/string integrity
print "Sequence size:";
print length($sequence); print " Printing sequence: $sequence";
print "\n\n\n";
print $promoter;
print "\n\n\n";
print "exon start: @estart \n";
print "intron start: @istart \n";
}
#################################################################################
sub init{ #fill in strings $sequence, $promoter and exon/intron table
$seqnam = 'sequence.txt';
$pronam = 'promoter.txt';
$indexnam = 'index.txt';
open($seqin, '<', $seqnam);
$sequence = <$seqin>;
close $seqin;
open($promin, '<', $pronam);
$promoter = <$promin>;
close $promin;
@estart;
@istart;
$indexnam = 'index.txt';
open($indexin, '<', $indexnam);
$prom_len = <$indexin>; # nab promoter length at line 1 of file
chomp($prom_len);
$prime = <$indexin>; #priming read, so we can check for signal -1776
chomp($prime);
for($c = 0; $prime != -1776;$c = $c + 1){#fill exon array
@estart[$c] = $prime;
$prime = <$indexin>;
chomp($prime);
}
$prime = <$indexin>; #reset priming read for introns
chomp($prime);
for($c = 0; $prime != -1776;$c = $c + 1){ #fill introns
@istart[$c] = $prime;
$prime = <$indexin>;
chomp($prime);
}
close $indexin;
print "@estart";
}
return 1;