Rename TGI

From RAJ INFO
Revision as of 13:23, 28 April 2010 by Raj (talk | contribs) (Created page with '<source lang=perl> #! /usr/bin/perl -w # ************************************************************* # This Programme does the following in sequence # -> Reads the 2 files (T…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<source lang=perl>

  1. ! /usr/bin/perl -w
  1. *************************************************************
  2. This Programme does the following in sequence
  3. -> Reads the 2 files (TGI)
  4. -> Reads the fasta, name appropriately and writes a concatenated outfile
  5. Author : Rajkumar (itc@rajkumar.in)
  6. Release: APR 2010
  7. *************************************************************
  1. Libraries

use strict; use Bio::Perl; use Bio::SearchIO; use Parallel::ForkManager;


  1. At the top: Time Start

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

  1. Variables

my $path = "/home/raj/bio"; my $datadir = "$path/tobacco/data"; my $singlet = "$datadir/tgi_singlet.fa"; my $contig = "$datadir/tgi_contig.fa"; my $outfile = "$datadir/tgi.fa";

my $pm = new Parallel::ForkManager(16);

my ($i) = $_; my (@files)= @_;


  1. Clear the Files

if (-e "$outfile") {`rm $outfile`;}


  1. Parsing the Contigs

print "\n\tParsing Contigs..";

my $in = Bio::SeqIO->new(-file => "$contig", -format => 'Fasta'); my $identifier; my $sequence;

while ( my $seq = $in->next_seq() ) {

$pm->start and next;

$identifier = $seq->id; $sequence = $seq->seq;

$identifier = "TGI_CON_".$identifier;

my ($fasta) = $_; $fasta = ">$identifier\n$sequence\n";

open (F, ">>".$outfile); print F $fasta; close F;

$pm->finish; }

$pm->wait_all_children; print " Done!\n";


  1. Parsing the Singlet

print "\n\tParsing Singlets..";

$in = Bio::SeqIO->new(-file => "$singlet", -format => 'Fasta');

while ( my $seq = $in->next_seq() ) {

$pm->start and next;

$identifier = $seq->id; $sequence = $seq->seq;

$identifier = "TGI_SIG_".$identifier;

my ($fasta) = $_; $fasta = ">$identifier\n$sequence\n";

open (F, ">>".$outfile); print F $fasta; close F;

$pm->finish; }

$pm->wait_all_children; print " Done!\n";


print "\n\tAll Done!\n\n";


  1. 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";

  1. END

</perl>