[ create a new paste ] login | about

Link: http://codepad.org/kOLTaKaR    [ raw code | output | fork ]

Perl, pasted on Feb 2:
    # Open blast output file
    my $blastres = new Bio::SearchIO(-format => 'blast',
                                     -file => $blastoutfname);

    # Now get identical hits store as an array containing a list of alternating names and $hsp data
    # @hits = ( $name1, $hsp1, $name2, $hsp2, .... ) $hspi == a SearchIO hsp object

    # blast hits
    my @hits = ();

    # cycle through all of the results
    while ( my $res = $blastres->next_result ) {



        # cycle through all of the hits within the result
        while( my $hit = $res->next_hit ) {
        #print "number of hsps:".$hit->hsps();

                #print "Number of HSPS in this hit ".$hit->name. ":".$hit->num_hsps();
                #print OUTFILE "Number of HSPS in this hit ".$hit->name. ":".$hit->num_hsps();

            # cycle through each hsp object
            while ( my $hsp = $hit->next_hsp ) {

                #print "\n\n[i m here in the hsp object \n\n\n";
                print "\n Number of hsps in this hit: ".$hsp->matches($hit);
                print "\n Num identical: ".$hsp->num_identical();

                # if the identity percentage between the query sequence and the resulting match is 100%, continue
                if ($hsp->frac_identical==1.0){

                    print "\n i m here in the 100% object \n\n\n";
                        #print $hsp->matches();
                        #print OUTFILE $hsp->matches();

                    # if the amino acid position of the mutation is within the sequence that matches between
                    # the original query and the result, continue
                    if($hsp->start('query') <= $pos && $hsp->end('query') >= $pos) {
                        print $hit->name, " ";
                        print $hsp->frac_identical(), " ";
                        print OUTFILE $hit->name, " ";
                        print OUTFILE $hsp->frac_identical(), " ";

                        # if the total length of the matched sequence section is more than 15 amino acids, keep it
                        # all of these special cases eliminates short strings of repeated characters and other such
                        # matches

                        if($hsp->length('total') > 15){
                            push( @hits, $hit->name, $hsp );
                        }
                    }
                }
            }
        }
    }


Output:
1
Can't locate object method "new" via package "Bio::SearchIO" (perhaps you forgot to load "Bio::SearchIO"?) at line 2.


Create a new paste based on this one


Comments: