I'm hoping you all can help me with a problem I have.
I have a fasta file of ~1300 genes, and I'm looking for all instances of 7 different 6nt sequences. I'm hoping to use my list of 7seven 6mers to query the fasta and extract the matches sequence (+/- about 7nt around it) as well as the match's respective fasta header.
This seems like something that would be really easy to do for someone who is good at programming. Unfortunately, I'm not. I've tried a couple different things- First I tried using grep, but the inflexibility of grep made it difficult to compile the data, especially keeping it attached to the FASTA header.
Next, I tried the following perl script (remember, I can't program) and I get errors each time.
use strict;
use Bio::Seq;
use Bio::DB::Fasta;
my $fastaFile = shift;
my $queryFile = shift;
my $db = Bio::DB::Fasta->new( $fastaFile );
open (IN, $queryFile);
while (<IN>){
chomp;
$seq = $_;
my $sequence = $db->seq($seq);
if (!defined( $sequence )) {
die "Sequence $seq not found. \n"
}
print ">$seq\n", "$sequence\n";
}
This gives me the output of :
Global symbol "$seq" requires explicit package name at seqfindr.pl line X.
for every line that contains $seq
.
Now, I've tried adjusting my PATH to contain all bioperl modules (I imagine, $seq
is contained in one) to no avail.
Can someone help me out here? I'm open to new ideas of how to generate my list, adjustments to the perl script, or reappropriation of other tools.
Thank you!
Stressed and under pressure from the boss :)
You're so nice! I'll run it tomorrow and let you know how it goes! Thanks Dan.
In general, would you recommend that I focus on Python instead of Perl for bioinformatics? While Python seems to be taking over, a lot of the tools out there are in Perl.
Uh oh, you opened that door. I think it's largely a matter of personal preference. The Python vs. Perl debate leaves lots of bodies in its wake. Here are some of the best biostars threads about it:
When To Choose Python Over Perl (And Vice Versa)?
I want to re-open the old debate: python or perl ?
Ahah! it worked! I am so grateful for your help, Dan. You have no idea how relieved I am!