-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate_GCcontent.pl
42 lines (40 loc) · 1.22 KB
/
calculate_GCcontent.pl
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
#!/bin/perl
# use strict;
#=============================================================================================
# This perl program is used to output the reverse complementary sequnce of the given sequence.
# Usage: perl ReverseSeq.pl <inputfafile.fa>
# Author: Yongqing Lan
# E-mail: [email protected]
# Date: 2015.12.26
#
#=============================================================================================
my ($in,$out)=@ARGV;
open IN, "<$in" || die "can't open the $in file!";
open OUT, ">>$out.GCcontent" || die "can't open the $out.GCcontent file!";
while (<IN>){
chomp;
print OUT "$_\n";
my $seq = <IN>;
chomp $seq;
my @seqarr = split (//,$seq);
my @gcarr;
for ($i=0; $i<=$#seqarr; $i++) {
if ($seqarr[$i] eq "G" or $seqarr[$i] eq "C" or $seqarr[$i] eq "g" or $seqarr[$i] eq "c"){
$gcarr[$i] = 1;
}
elsif ($seqarr[$i] eq "A" or $seqarr[$i] eq "T" or $seqarr[$i] eq "a" or $seqarr[$i] eq "t") {
$gcarr[$i] = 0;
}
}
my $winnum = $#gcarr - 27;
for ($j=0; $j<=$winnum; $j++){
my $gcsum = 0;
map { $gcsum += $_} @gcarr[$j..$j+27];
my $gcmean = $gcsum / 28;
if ($gcmean >= 0.5){
print OUT "$j $gcmean\n";
}
}
}
close IN;
close OUT;