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

View of /FigKernelScripts/svr_tips_of_tree.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (download) (as text) (annotate)
Sat Sep 18 20:22:23 2010 UTC (9 years, 2 months 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, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, mgrast_dev_06072011, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2011_0119, 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
Changes since 1.1: +51 -2 lines
add correspondence translation

########################################################################
#! /usr/bin/perl -w
#
#  svr_tips_of_tree -- Extracts the tips from a file containing trees
#


use strict;
use Data::Dumper;
use gjonewicklib;



=head1 svr_tips_of_tree

=head2 Introduction

    svr_tips_of_tree < tree(s) > tips

Reads a file of one or more trees in Newick format and returns the tips.

=head2 Command-Line Options

=over 4

=item -c=Table

A correspondence table in which the first two columns contain pairs of IDs,
one of which must be a FIG ID.

=back

=head3 Output Format

The generated HTML document is written to STDOUT.

=cut

use Getopt::Long; 
my $corr;

my $rc = GetOptions("-c=s",\$corr);

my %corrH;
if ($corr)
{
    if (-s $corr)
    {
	open(CORR,"<$corr") || die "could not open $corr";
	while ($_ = <CORR>)
	{
	    if ($_ =~ /^(\S+)\s+(\S+)/)
	    {
		my $id1 = $1;
		my $id2 = $2;
		if ($id1 =~ /^fig\|\d+\.\d+\.peg\.\d+/)
		{
		    $corrH{$id2} = $id1;
		}
		elsif ($id2 =~ /^fig\|\d+\.\d+\.peg\.\d+/)
		{
		    $corrH{$id1} = $id2;
		}
	    }
	    else
	    {
		print STDERR "Ignoring: $_";
	    }
	}
	close(CORR);
    }
    else
    {
	die "invalid correspondence table";
    }
}
my @trees = &gjonewicklib::read_newick_trees;

my %tips = map{ $_ => 1 } map { &gjonewicklib::newick_tip_list($_) } @trees;

foreach $_ (sort { lc $a cmp lc $b } keys(%tips))
{
    my $tip = $corrH{$_} ? $corrH{$_} : $_;
    print "$tip\n";
}
    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3