[Bio] / FigKernelScripts / svr_add_lengths_to_blast.pl Repository:
ViewVC logotype

View of /FigKernelScripts/svr_add_lengths_to_blast.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Feb 18 13:39:11 2011 UTC (9 years ago) by overbeek
Branch: MAIN
CVS Tags: mgrast_dev_08112011, mgrast_dev_08022011, rast_rel_2014_0912, myrast_rel40, mgrast_dev_05262011, mgrast_dev_04082011, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, mgrast_release_3_0, mgrast_dev_03252011, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, mgrast_dev_10262011, HEAD
 simple utility to add sequence lengths to m8 blast output

use strict;
use Data::Dumper;
use Carp;
use gjoseqlib;

#
# This is a SAS Component
#


=head1 svr_add_lengths_to_blast

Add query and contig lengths to m8 blast output

------

Example:

    svr_add_lengths_to_blast -i queryF -d db < blast.m8 > with.2.extra.columns

=head2 Command-Line Options

=over 4

=item -i queryF

This gives the name of the file containing the query sequences  in FAST format

=item -d db

This gives the name of the file containing the db contigs in FAST format

=back

=head2 Output Format

The output is the m8 blast output with two columns added.  The first
is the length of the query sequence, and the second is the length
of the db contig.

=cut

use SeedUtils;
use SAPserver;
my $sapObject = SAPserver->new();
use Getopt::Long;

my $usage = "usage: svr_add_lengths_to_blast -i queryF -d dbF";

my $queryF;
my $dbF;
my $rc  = GetOptions('i=s' => \$queryF, 'd=s' => \$dbF);
if ((! $rc) || (! $queryF) || (! $dbF)) { print STDERR $usage; exit }

my @query_seqs = &gjoseqlib::read_fasta($queryF);
my %queryH = map { ($_->[0] => length($_->[2])) } @query_seqs;

my @db_seqs = &gjoseqlib::read_fasta($dbF);
my %dbH = map { ($_->[0] => length($_->[2])) } @db_seqs;

while (defined($_ = <STDIN>))
{
    chop;
    my @flds = split(/\s+/,$_);
    print join("\t",@flds),"\t",$queryH{$flds[0]},"\t",$dbH{$flds[1]},"\n";
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3