One error I found was the last sequence wasn't being added to the %protein hash. You need to add it at the end of the while loop.
{ open (IN, $file) || die "Can't open $file\n"; my $tag; my $seq; while (<IN>) { chomp; if (/^>/) { if ($seq) {$protein{$tag} = uc($seq); undef $seq} $tag = $_; } else {$seq .= $_} } $protein{$tag} = uc($seq); # add this line to get the last sequence close IN; }
With a few other adjustments, I was able to get the script to run. However, I don't know what changes need to be made to get accurate results.

With an inputfile of:

>chr1 RecName: Full=Putative transcription factor 001R; MAFSAEDVLKEYDRRRRMEALLLSLYYPNDRKLLDYKEWSPPRVQVECPKAPVEWNNPPS EKGLIVGHFSGIKYKGEKAQASEVDVNKMCCWVSKFKDAMRRYQGIQTCKIPGKVLSDLD AKIKAYNLTVEGVEGFVRYSRVTKQHVAAFLKELRHSKQYENVNLIHYILTDKRVDIQHL EKDLVKDFKALVESAHRMRQGHMINVKYILYQLLKKHGHGPDGPDILTVKTGSKGVLYDD SFRKIYTDLGWKFTPL >chr2 RecName: Full=Uncharacterized protein 002L; MSIIGATRLQNDKSDTYSAGPCYAGGCSAFTPRGTCGKDWDLGEQTCASGFCTSQPLCAR IKKTQVCGLRYSSKGKDPLVSAEWDSRGAPYVRCTYDADLIDTQAQVDQFVSMFGESPSL AERYCMRGVKNTAGELVSRVSSDADPAGGWCRKWYSAHRGPDQDAALGSFCIKNPGAADC KCINRASDPVYQKVKTLHAYPDQCWYVPCAADVGELKMGTQRDTPTNCPTQVCQIVFNML DDGSVTMDDVKNTINCDFSKYVPPPPPPKPTPPTPPTPPTPPTPPTPPTPPTPRPVHNRK VMFFVAGAVLVAILISTVRW
I got results from your program below
>chr1 RecName: Full=Putative transcription factor 001R; 9.425903320 +3125 >chr2 RecName: Full=Uncharacterized protein 002L; 8.2193603515625
These results vary from a program I wrote using Bio::Tools::pICalculator. The results I got from it were:
chr1 9.793558 chr2 7.791410
That program code was:
#!/usr/bin/perl use strict; use warnings; use Bio::Tools::pICalculator; use Bio::SeqIO; @ARGV == 1 or die "Usage: perl $0 fasta_file_name\n"; my $in = Bio::SeqIO->new( -file => $ARGV[0] ,-format => 'Fasta' ); my $calc = Bio::Tools::pICalculator->new(-places => 6); while ( my $seq = $in->next_seq ) { $calc->seq($seq); my $iep = $calc->iep; print join("\t", $seq->id, $iep), "\n"; }
I got the code from the documentation for that module.

Chris


In reply to Re: Iso electric point calculation using perl by Cristoforo
in thread Iso electric point calculation using perl by yuvraj_ghaly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.