#!/usr/bin/perl
use DBI;
$dbh = DBI->connect('DBI:mysql:meta', 'root', 'password'
) || die "Could not connect to database: $DBI::errstr";
my ($infile) = @ARGV;
open(IN, "$infile");
my $jcvi_read,$leng,$gccont=0,$gcskew=0,$seq="";
while(my $line =
chomp($line);
if ($line =~ /^\>/) {#reading header line
if($jcvi_read !=0){
$gccont=($gccont/$leng)*100;
$dbh->do("INSERT into metadata (jcvi_read,full_length,gc_content,gc_skew_orient,sequence) VALUES('$jcvi_read','$leng','$gccont','$gcskew','$seq')");#inserting the data into mySql Database
}
$gccont=0;
$seq="";
my @a = split(/\//, $line);
my @b = split(/\_/, $a[0]);
$jcvi_read = $b[2];
my @c = split(/\=/, $a[1]);
$leng = $c[1];
# print $jcvi_read."\n";
}
else{#reading and analysing the sequence
$seq = $seq.$line;
my @char =split(//,$line);
foreach(@char){
if($_ eq "G"|| $_ eq "C"){$gccont++;}# Calculating GC content
if($_ eq "G"){$gcskew++;}#Calcualting GC skew
if($_ eq "C"){$gcskew--;}
}
}
#print $gcskew."\n";
}
$dbh->disconnect();
1 comment:
What did you say
Post a Comment