Misa run1.pl: Difference between revisions

From RAJ INFO
Jump to navigation Jump to search
m New page: <source lang=perl> #! /usr/bin/perl -w # ************************************************************* # This Programme does the following in sequence # -> Open the misa results # -> Par...
 
mNo edit summary
 
Line 1: Line 1:
<source lang=perl>
<source lang=perl>
#! /usr/bin/perl -w
#! /usr/bin/perl -w


# *************************************************************
# *************************************************************
# This Programme does the following in sequence
# This Programme does the following in sequence
# -> Open the misa results
# -> Runs MISA
# -> Parse the files
# -> Produces 2 outfiles, one ssr and other statistics
# -> compare the original EST file and pick the sequence that have repeats
# Author: Author: Thomas Thiel ; Modified by Rajkumar (itc@rajkumar.in)
# -> Outputs as fasta
# Release: JUL 2008
# Author: Rajkumar (itc@rajkumar.in)
 
# *************************************************************
# *************************************************************


# Libraries
# Libraries
use strict;
use strict;
use Bio::SeqIO;
use Bio::Perl;


# At the top: Time Start
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);


# Variables
# Variables
my $path    = "/home/raj/bio";
my $path    = "/home/raj/bio";
my $ssrdir  = "$path/euca/ssr";
my $ssrdir  = "$path/euca/ssr/glo-gra-ssr";
my $datadir = "$ssrdir/data";
my $infile  = "$ssrdir/camal_grand.fa";
my $resdir  = "$ssrdir/result";
my $resdir  = "$ssrdir/result";
my $est    = "$datadir/globulus_est_trim.fa";
my $repeat  = "$resdir/globulus_est_trim.fa.misa";
my $resfile = "$datadir/globulus_est_repeat.fa";
my ($i, $ssr_id, $total, $math ) = $_;
my (@repeat_id, @identifier) = @_;
 
# Function
# Lets Clean it
if (-e "$resfile") {`rm $resfile`;}


# start your hack
# Running the File


open(CSV, "$repeat") or die "Idiot! Where is that Misa Outfile ? 'CSV': $!\n";
if (-e "$resdir") {`rm -fr $resdir`;}
<CSV>; # skip header line
if (! -e "$resdir") {`mkdir $resdir`;}
while (my $line = <CSV>) {
my ($ssr_id) = split('\t', $line);
chdir $ssrdir;
next if ($ssr_id =~ m/^ID/);
`./misa.pl $infile`;
push (@repeat_id, "$ssr_id");
}


# Making them Unique
my %seen;
my @unique_repeat_id = grep !$seen{$_}++, @repeat_id;
# Getting some statistics
my $count_unique_repeat_id = @unique_repeat_id;
$i = 0;
# Lets Grab the sequence
foreach my $repeat_id(@unique_repeat_id) {
$i++;
my $in  = Bio::SeqIO->new(-file => "$est", -format => 'Fasta');
my $identifier;
my $sequence;
while ( my $seq = $in->next_seq() ) {
$identifier = $seq->id;
$sequence  = $seq->seq;
next if ($repeat_id ne $identifier);
if ($repeat_id eq $identifier) {
my $fasta  = ">$identifier\n$sequence\n";
open (FH, ">>".$resfile);
print FH $fasta ;
close FH ;
print "\r\tWritten $identifier. Still $i of $count_unique_repeat_id to be written!";
}
  }
}


print "\n\tDone All Man\nOutfile written into $resfile\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
# END
</source>
</source>

Latest revision as of 10:35, 30 December 2009

#! /usr/bin/perl -w

# *************************************************************
# This Programme does the following in sequence
# -> Runs MISA
# -> Produces 2 outfiles, one ssr and other statistics
# Author: Author: Thomas Thiel ; Modified by Rajkumar (itc@rajkumar.in)
# Release: JUL 2008
# *************************************************************

# Libraries
	use strict;

# At the top: Time Start
	my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

# Variables
	my $path    = "/home/raj/bio";
	my $ssrdir  = "$path/euca/ssr/glo-gra-ssr";
	my $infile  = "$ssrdir/camal_grand.fa";
	my $resdir  = "$ssrdir/result";
	 

# Running the File

	if (-e "$resdir") {`rm -fr $resdir`;}
	if (! -e "$resdir") {`mkdir $resdir`;}
	
	chdir $ssrdir;
	`./misa.pl $infile`;


# 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