Created
April 7, 2011 15:18
-
-
Save dbolser/907984 to your computer and use it in GitHub Desktop.
bp_seq_load.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' | |
| if 0; # not running under some shell | |
| use strict; | |
| use Getopt::Long; | |
| use Bio::DB::SeqFeature::Store; | |
| use Bio::SeqIO; | |
| my $DSN = 'dbi:mysql:test'; | |
| my $SFCLASS = 'Bio::DB::SeqFeature'; | |
| my $ADAPTOR = 'DBI::mysql'; | |
| my $NAMESPACE; | |
| my $VERBOSE = 1; | |
| my $FAST = 0; | |
| my $TMP = File::Spec->tmpdir(); | |
| my $IGNORE_SEQREGION = 0; | |
| my $CREATE = 0; | |
| my $USER = ''; | |
| my $PASS = ''; | |
| my $COMPRESS = 0; | |
| my $INDEX_SUB = 1; | |
| my $NOALIAS_TARGET = 0; | |
| my $SUMMARY_STATS = 0; | |
| GetOptions( | |
| 'dsn=s' => \$DSN, | |
| 'seqfeature=s' => \$SFCLASS, | |
| 'namespace=s' => \$NAMESPACE, | |
| 'adaptor=s' => \$ADAPTOR, | |
| 'verbose!' => \$VERBOSE, | |
| 'create' => \$CREATE, | |
| 'user=s' => \$USER, | |
| 'password=s' => \$PASS, | |
| 'S|subfeatures!' => \$INDEX_SUB, | |
| 'noalias-target' => \$NOALIAS_TARGET, | |
| ) || die <<END; | |
| Usage: $0 [options] gff_file1 gff_file2... | |
| Options: | |
| -d --dsn The database name ($DSN) | |
| -n --namespace The table prefix, excluding ($NAMESPACE) | |
| -s --seqfeature The type of SeqFeature to create ($SFCLASS) | |
| -a --adaptor The storage adaptor to use ($ADAPTOR) | |
| -v --verbose Turn on verbose progress reporting | |
| --noverbose Turn off verbose progress reporting | |
| -c --create Create the database and reinitialize it (will erase contents) | |
| -u --user User to connect to database as | |
| -p --password Password to use to connect to database | |
| END | |
| my @options; | |
| @options = ($USER,$PASS) if $USER || $PASS; | |
| my $store = Bio::DB::SeqFeature::Store->new | |
| ( | |
| -dsn => $DSN, | |
| -namespace => $NAMESPACE, | |
| -adaptor => $ADAPTOR, | |
| -user => $USER, | |
| -pass => $PASS, | |
| -write => 1, | |
| -create => $CREATE, | |
| ) | |
| or die "Couldn't create connection to the database"; | |
| $store->init_database('erase') if $CREATE; | |
| $SUMMARY_STATS++ if $CREATE; # this is a good thing | |
| my $seq_io = Bio::SeqIO-> | |
| new(-file => "<$ARGV[0]"); | |
| while (my $seq_obj = $seq_io->next_seq) { | |
| $store-> | |
| insert_sequence( $seq_obj->accession_number, | |
| $seq_obj->seq | |
| ); | |
| } | |
| exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment