#! /usr/bin/perl -w

##### Program description #######
#
# Title:     bp_ex8.pl
# Author(s): Mattias Ohlsson
# Description:
#   An example of the OddCodes module
#
##################################

use strict;
use Bio::SeqIO;
use Bio::Tools::OddCodes;

# Read the file containing fasta sequences
my $in  = Bio::SeqIO->new(-fh => \*STDIN, -format => 'Fasta');

# Make a loop over all the sequences
while ( my $seq = $in->next_seq() ) {
    
    # Create a an OddCodes object
    my $odd = Bio::Tools::OddCodes->new(-seq => $seq);
    
    # Make a hydrophobic sequence
    my $hseq_ref = $odd->hydrophobic();

    # Get the aa sequence
    my $aaseq = $seq->seq();
    
    # Make a nice printout
    my $Id = $seq->display_id();
    print ">>>>ID: $Id\n";

    my @tmp1 = ($aaseq =~ /(.{1,50})/g);
    my @tmp2 = (${$hseq_ref} =~ /(.{1,50})/g);
    
    my $len = @tmp1;
    for ( my $i = 0; $i < $len; $i++ ) {
	print "$tmp1[$i]\n";
	print "$tmp2[$i]\n\n";
    }
}
