From: elserj Date: Wed, 4 May 2011 17:51:43 +0000 (+0000) Subject: Add file to create a fasta protein file from a list of genes X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=1825399d0864d0ab42b6bc647bbacb52fdf4970d;p=old-jaiswallab-svn%2F.git Add file to create a fasta protein file from a list of genes svn path=/; revision=92 --- diff --git a/interactome_scripts/make_fasta_from_gene_list.pl b/interactome_scripts/make_fasta_from_gene_list.pl new file mode 100755 index 0000000..45be6a4 --- /dev/null +++ b/interactome_scripts/make_fasta_from_gene_list.pl @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib "$ENV{HOME}/scripts/jaiswallab/interactome_scripts"; + +use DbiFloret; + +if ($#ARGV != 2) { + print "usage: make_fasta_from_gene_list.pl species gene_list output_file\n"; + exit; +} + +my $species = $ARGV[0]; + +my $gene_list_file = $ARGV[1];; + +my @genes; +open(gene_file, $gene_list_file); +while() { + my $line = $_; + chomp $line; + push (@genes, $line); +} +close(gene_file); + +my $dbh = DbiFloret::dbconnect; + +my $safe_species = $dbh->quote_identifier($species); + +my $sth_get_sequence = $dbh->prepare("select sequence from $safe_species where gene_id like ?"); + +open(outputfh, ">$ARGV[2]"); + +foreach my $gene (@genes) { + $sth_get_sequence->execute($gene); + print outputfh ">$gene\n"; + while (my @line = $sth_get_sequence->fetchrow_array) { + my $line = $line[0]; + my $len = length($line); + for (my $pos=0; $pos < $len; $pos+=80) { + print outputfh substr($line, $pos, 80), "\n"; + } + } +} +close(outputfh); +