#! /usr/bin/perl -w
# *************************************************************
# This Programme does the following in sequence
# -> Open a multi fasta file
# -> Count the number of bases in each fasta
# -> output need to be captured
# Author: Rajkumar (itc@rajkumar.in)
# *************************************************************
# Libraries
use strict;
use Bio::SeqIO;
# Variables
my $path = "/home/raj/bio";
# Getting the input file
my $argcount = @ARGV;
if ($argcount !=1 ) {die "\n\t ->Usage: Type infile!\n\n";}
my ($infile,$outfile) = @ARGV;
my @seq;
# Function
chomp($infile);
my $input = `cat $infile`;
$input =~ s/[\"|(|)|:]//g;
$input =~ s/[ ]+/_/g;
$input =~ s/.abi//g;
open(TEMP, ">tempfile");
print TEMP $input;
close TEMP;
my $in = Bio::SeqIO->new(-file => "tempfile", -format => 'Fasta');
my $identifier;
my $sequence;
while ( my $seq = $in->next_seq() ) {
$identifier = $seq->id;
$sequence = $seq->seq;
# print ">$identifier\n$sequence\n";
my $length = ($sequence =~ tr/[A-Z]|[a-z]//);
print "$identifier\t$length\n";
}
`rm tempfile`;
# END