-.- not regular expression...
script was a huge success
perl code:
#!/usr/bin/perl -w
use strict;
use warnings;
my @genome;
my $genome;
my $length;
my $Wi;my $X;my $Y; #for math
#opens input
open(my $fh, "<", "input.gbk") or die "cannot open < test.gbk: $!";
#opens output and prints header
open(MYOUTFILE, ">test.out") or die "could not open test.out";
print MYOUTFILE "Start:End:A-tract:Xi:Yi:Angle\n";
#imports file removes spaces and digits
while (my $line = <$fh>) {
if ($line =~ /[\d|\s]{8}\d\s\D{10}\s\D{10}\s\D{10}\s\D{10}/) {
push (@genome, $line);
}
}
$genome = "@genome";
$genome =~ s/\s|\d//g;
# searches $genome, does math, prints output.
while ($genome =~ /a+t?|t+/g) {
$length = $+[0] - $-[0];
if ( $length == 4 or $length == 5 or $length == 6 or $length == 7 ) {
$Wi = (((($-[0] + $+[0]) / 2) / 10) * 6.28318531);
$Y = sin $Wi;
$X = cos $Wi;
print MYOUTFILE "$-[0]:$+[0]:$&:$X:$Y:";
if ( $length == 4 or $length == 7 ) {
print MYOUTFILE "15\n";
}
if ( $length == 5 or $length == 6 ) {
print MYOUTFILE "20\n";
}
}
}
Last edited by Orion; Jun 22, 2011 at 08:33 PM.