Tgicl parse.pl: Difference between revisions
Jump to navigation
Jump to search
m New page: <source lang=perl> #! /usr/bin/perl -w # ************************************************************* # This Programme does the following in sequence # -> Open a results folder of TGICL... |
mNo edit summary |
||
| Line 18: | Line 18: | ||
## Variables | ## Variables | ||
my $path | my $path = "/home/raj/bio"; | ||
my $resdir | my $resdir = "$path/euca/unigene"; | ||
my $singlets = "$resdir/globulus_singlets.fa"; | my $singlets = "$resdir/globulus_singlets.fa"; | ||
my $contigs | my $contigs = "$resdir/globulus_contigs.fa"; | ||
my $unigenes = "$resdir/globulus_unigenes.fa"; | my $unigenes = "$resdir/globulus_unigenes.fa"; | ||
my $contigs_temp = "$resdir/contigs_temp.fa"; | |||
| Line 32: | Line 33: | ||
if (-e "$contigs") {`rm $contigs`;} | if (-e "$contigs") {`rm $contigs`;} | ||
if (-e "$unigenes") {`rm $unigenes`;} | if (-e "$unigenes") {`rm $unigenes`;} | ||
if (-e "$contigs_temp") {`rm $contigs_temp`;} | |||
foreach my $asm (@asmdir) { | foreach my $asm (@asmdir) { | ||
`cat $resdir/result/$asm/contigs >>$ | `cat $resdir/result/$asm/contigs >>$contigs_temp`; | ||
`cat $resdir/result/$asm/singlets >>$singlets`; | `cat $resdir/result/$asm/singlets >>$singlets`; | ||
} | } | ||
# Removing the contigs that have more than or equal to 5 EST pices | |||
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; | |||
my $contig_id = "$identifier"; | |||
if ($contig_id =~ m/^(CL[0-9]+)Contig[0-9]+/g) { $contig_id = $1; } | |||
next if ($contig_id eq "CL1"); | |||
next if ($contig_id eq "CL2"); | |||
next if ($contig_id eq "CL3"); | |||
next if ($contig_id eq "CL4"); | |||
next if ($contig_id eq "CL5"); | |||
next if ($contig_id eq "CL6"); | |||
next if ($contig_id eq "CL7"); | |||
next if ($contig_id eq "CL8"); | |||
next if ($contig_id eq "CL9"); | |||
next if ($contig_id eq "CL10"); | |||
next if ($contig_id eq "CL11"); | |||
next if ($contig_id eq "CL12"); | |||
next if ($contig_id eq "CL13"); | |||
next if ($contig_id eq "CL14"); | |||
next if ($contig_id eq "CL15"); | |||
next if ($contig_id eq "CL16"); | |||
next if ($contig_id eq "CL17"); | |||
next if ($contig_id eq "CL18"); | |||
next if ($contig_id eq "CL19"); | |||
next if ($contig_id eq "CL20"); | |||
next if ($contig_id eq "CL21"); | |||
next if ($contig_id eq "CL22"); | |||
next if ($contig_id eq "CL23"); | |||
next if ($contig_id eq "CL24"); | |||
next if ($contig_id eq "CL25"); | |||
next if ($contig_id eq "CL26"); | |||
next if ($contig_id eq "CL27"); | |||
next if ($contig_id eq "CL28"); | |||
next if ($contig_id eq "CL29"); | |||
my $fasta = ">$contig_id\n$sequence\n"; | |||
open (H, ">>".$contigs); | |||
print H "$fasta"; | |||
close H; | |||
} | |||
#Finally write the unigenes | |||
`cat $contigs $singlets >$unigenes`; | `cat $contigs $singlets >$unigenes`; | ||
# END | # END | ||
</source> | </source> | ||
Latest revision as of 13:44, 28 December 2009
#! /usr/bin/perl -w
# *************************************************************
# This Programme does the following in sequence
# -> Open a results folder of TGICL
# -> parse the contigs and singlets
# -> Output as multifasta of single file
# Author: Rajkumar (itc@rajkumar.in)
# *************************************************************
# Libraries
use strict;
use Bio::SeqIO;
use Bio::Perl;
## Variables
my $path = "/home/raj/bio";
my $resdir = "$path/euca/unigene";
my $singlets = "$resdir/globulus_singlets.fa";
my $contigs = "$resdir/globulus_contigs.fa";
my $unigenes = "$resdir/globulus_unigenes.fa";
my $contigs_temp = "$resdir/contigs_temp.fa";
my @asmdir = ("asm_1", "asm_2", "asm_3", "asm_4");
# Getting the grip
if (-e "$singlets") {`rm $singlets`;}
if (-e "$contigs") {`rm $contigs`;}
if (-e "$unigenes") {`rm $unigenes`;}
if (-e "$contigs_temp") {`rm $contigs_temp`;}
foreach my $asm (@asmdir) {
`cat $resdir/result/$asm/contigs >>$contigs_temp`;
`cat $resdir/result/$asm/singlets >>$singlets`;
}
# Removing the contigs that have more than or equal to 5 EST pices
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;
my $contig_id = "$identifier";
if ($contig_id =~ m/^(CL[0-9]+)Contig[0-9]+/g) { $contig_id = $1; }
next if ($contig_id eq "CL1");
next if ($contig_id eq "CL2");
next if ($contig_id eq "CL3");
next if ($contig_id eq "CL4");
next if ($contig_id eq "CL5");
next if ($contig_id eq "CL6");
next if ($contig_id eq "CL7");
next if ($contig_id eq "CL8");
next if ($contig_id eq "CL9");
next if ($contig_id eq "CL10");
next if ($contig_id eq "CL11");
next if ($contig_id eq "CL12");
next if ($contig_id eq "CL13");
next if ($contig_id eq "CL14");
next if ($contig_id eq "CL15");
next if ($contig_id eq "CL16");
next if ($contig_id eq "CL17");
next if ($contig_id eq "CL18");
next if ($contig_id eq "CL19");
next if ($contig_id eq "CL20");
next if ($contig_id eq "CL21");
next if ($contig_id eq "CL22");
next if ($contig_id eq "CL23");
next if ($contig_id eq "CL24");
next if ($contig_id eq "CL25");
next if ($contig_id eq "CL26");
next if ($contig_id eq "CL27");
next if ($contig_id eq "CL28");
next if ($contig_id eq "CL29");
my $fasta = ">$contig_id\n$sequence\n";
open (H, ">>".$contigs);
print H "$fasta";
close H;
}
#Finally write the unigenes
`cat $contigs $singlets >$unigenes`;
# END