Parse assemblage ITC EST-TOBEA EST
Jump to navigation
Jump to search
#! /usr/bin/perl -w
# *************************************************************
# This Programme does the following in sequence
# -> Parses the TGCL results and assembles as singlets and contigs
# -> single cored
# Author : Rajkumar (itc@rajkumar.in)
# Release: MAY 2010
# *************************************************************
# Libraries
use strict;
use Bio::Perl;
use Bio::SearchIO;
use Parallel::ForkManager;
# At the top: Time Start
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
# Variables
my $path = "/home/raj/bio";
my $curdir = "$path/tobacco/data";
my $resdir = "$curdir/unigene_result";
my $singlets = "$resdir/singlets";
my $contigs = "$resdir/contigs";
my $singlets_temp = "$resdir/singlets_temp";
my $contigs_temp = "$resdir/contigs_temp";
my $unigenes = "$curdir/unigenes.fa";
my ($i) = $_;
my (@asm) = @_;
# Clear the Files
if (-e "$singlets") {`rm $singlets`;}
if (-e "$contigs") {`rm $contigs`;}
if (-e "$singlets_temp") {`rm $singlets_temp`;}
if (-e "$contigs_temp") {`rm $contigs_temp`;}
if (-e "$unigenes") {`rm $unigenes`;}
# Parsing the Contigs
opendir (DIR, "$resdir") or die $!;
@asm = readdir(DIR);
close(DIR);
foreach my $asm (@asm) {
if ($asm !~ m/^asm_/) {next;}
`cat $resdir/$asm/contigs >>$contigs_temp`;
`cat $resdir/$asm/singlets >>$singlets_temp`;
}
# Renaming and Writing the final Unigenes (contigs)
my $in = Bio::SeqIO->new(-file => "$contigs_temp", -format => 'Fasta');
my $identifier;
my $sequence;
while ( my $seq = $in->next_seq() ) {
$identifier = $seq->id;
$sequence = $seq->seq;
$identifier = "UNI_CON_".$identifier;
my ($fasta) = $_;
$fasta = ">$identifier\n$sequence\n";
open (F, ">>".$unigenes);
print F $fasta;
close F;
}
# Renaming and Writing the final Unigenes (singlets)
$in = Bio::SeqIO->new(-file => "$singlets_temp", -format => 'Fasta');
while ( my $seq = $in->next_seq() ) {
$identifier = $seq->id;
$sequence = $seq->seq;
$identifier = "UNI_SIN_".$identifier;
my ($fasta) = $_;
$fasta = ">$identifier\n$sequence\n";
open (F, ">>".$unigenes);
print F $fasta;
close F;
}
print "\n\tAll Done!\n\n";
# At the End: Time Calculation
my ($sec_,$min_,$hour_,$mday_,$mon_,$year_,$wday_,$yday_,$isdst_) = localtime(time);
my $days = $mday_-$mday;
my $hours = $hour_-$hour;
my $mins = $min_-$min;
my $secs = $sec_-$sec;
print "\n------------------------\nDuration: ";
if ($days>0) { print "$days days";}
if ($hours>0) { print ": $hours hours";}
if ($mins>0) { print ": $mins mins";}
if ($secs>0) { print ": $secs secs";}
print "\n------------------------\n";
# END