in reply to Re^2: New to Perl
in thread New to Perl

The $query is suppose to be the key for the hash which will be the the ID from the FASTA sequence

Replies are listed 'Best First'.
Re^4: New to Perl
by chromatic (Archbishop) on Aug 04, 2011 at 22:19 UTC

    Is the solution as simple as using chomp on the lines of your array?

      no ok it can't be. Ok let me see if I can explain it a different way and tell you what the program needs to do. First ask me to enter the clone ID. After i enter the ID using something like $id=<STDIN>; search thru my FASTA file and give me as an answer the sequence from the ID I put in, do you get me? by the way I can't thank you enough for helping me
        This is the code I have until now, it is telling me Odd number of elements in hahs assigment at line 17, any ideas
        #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; } }