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

View of /FigKernelScripts/solid_rectangles_to_solid_families.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Tue Feb 26 14:05:29 2013 UTC (6 years, 9 months ago) by overbeek
Branch: MAIN
CVS Tags: rast_rel_2014_0729, rast_rel_2014_0912, HEAD
format output

use Data::Dumper;
use strict;
use Getopt::Long;
use FIG;
my $fig = new FIG;

my $md5s = 0;
my $out  = "";

my $usage = "usage: solid_rectangles_to_solid_families -o OutputFile [-m to get md5s]\n";
my $rc  = GetOptions('m'   => \$md5s,
		     'o=s' => \$out);
if ((! $rc) || (! $out)) { print STDERR $usage; exit }

open(OUT,"| sort -T . -k 1 -n > $out") || die "could not open output";

my %seen;
my $nxt_set = 1;

$/ = "\n//\n";
while (defined($_ = <STDIN>))
{
    chomp;
    my @lines = map { ($_ =~ /^\S+\t(\S.*\S)/) ? [split(/\t/,$1)] : () } split(/\n/,$_);
    if (@lines > 1)
    {
	print STDERR "set of ",scalar @lines,"\n";

	my $i; 
	for ($i=0; ($i < @{$lines[0]}); $i++)
	{
	    my @set     = map { $_->[$i] } @lines;
	    my @set     = map { $fig->md5_of_peg($_) } @set;
	    my @n       = grep { $seen{$_} } @set;
	    my $setN    = (@n == 0) ? $nxt_set++ : $n[0];
	    my %entries = map { ($_ => 1) } @set;
	    @set        = map { $md5s ? $_ : $fig->pegs_with_md5($_) } keys(%entries);
	    @set        = sort { $md5s ? ($a cmp $b) : &SeedUtils::by_fig_id($a,$b) } @set;
	    foreach $_ (@set)
	    {
		print OUT join("\t",($setN,$_)),"\n";
	    }
	}
    }
}
close(OUT);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3