[Bio] / FigMetagenomeTools / load_454_bp.pl Repository:
ViewVC logotype

View of /FigMetagenomeTools/load_454_bp.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Fri Mar 16 20:51:25 2007 UTC (12 years, 8 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, mgrast_rel_2008_0806, mgrast_dev_10262011, mgrast_dev_02212011, mgrast_rel_2008_0923, mgrast_release_3_0, mgrast_dev_03252011, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, mgrast_rel_2008_0625, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, mgrast_rel_2008_0919, mgrast_rel_2008_1110, myrast_33, mgrast_rel_2008_0917, mgrast_dev_04052011, mgrast_dev_02222011, HEAD
Changes since 1.1: +0 -1 lines
initial tweaks

#!/usr/bin/perl -w

use strict;
use DBI;
use Rob;
my $rob=new Rob;
# load the 454 sequences into the database
my $dbh=DBI->connect("DBI:mysql:sequences", "rob", "forestry") or die "Can't connect to database\n";

my %got;
# read what we have so we don't add them twice
{
	my $exc=$dbh->prepare("select id from rawseqs") || die $dbh->errstr;
	$exc->execute || die $dbh->errstr;
	while (my @ret=$exc->fetchrow_array) {$got{$ret[0]}=1}
}
print STDERR "there are ", scalar(keys %got), " sequences in the database already\n";


foreach my $f (@ARGV)
{
 unless (-e $f) {print STDERR "$f not found\n"; next}
 print STDERR "$f began at ", scalar(localtime(time)), "\n";
 my $fa=$rob->read_fasta($f);
 my @keys=grep {!$got{$_}} sort {$a <=> $b} keys %$fa;
 print STDERR "$f\t", scalar(@keys), "\n";
 foreach my $k (@keys)
 {
  next if ($got{$k}); # don't add the ones that we already have
  $fa->{$k}=~ s/\s+//g;
  my $exc=$dbh->prepare("insert into rawseqs (count, id, sequence) values ('', '$k', '".$fa->{$k}."')") || die $dbh->errstr;
  $exc->execute || die $dbh->errstr;
 }
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3