in reply to Re^5: New to Perl
in thread New to Perl
#the file name $filename= hwk2.seq; use strict; use warnings; use lib '/class/bi617a/share/textbook'; use BeginPerlBioinfo; #Declare initialize the variables my @file_data=(); my %seqs= ''; my $query= ''; my $dna= ''; #Read the contents of the file hwk3.seq @file_data=get_file_data("hwk2.seq"); print "Please enter the clone ID:\n"; $query=<STDIN>; chomp $query; my $seqs= &get_fasta(@file_data); if (exists $seqs{$query}) { print " This is the sequence: $seqs{$query +}, \n"; } else{ print "Not an ID\n\n;";} exit; sub get_fasta{ my $header; my $first = 0; for my $file_data(@file_data){ if ($file_data =~ /^>/) { $query = $file_data; $query=~ s/^>//; $query=~ s/\s,*//; if ($first == 0) { $first =1; } next; } if ($first == 0) {die("Not a standard FASTA file.\n"); } $seqs{$query} = $file_data; return \%seqs; } } return \%seqs; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: New to Perl
by Anonymous Monk on Aug 06, 2011 at 06:23 UTC |