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

Annotation of /FigKernelScripts/solid_rectangles_to_solid_families.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : overbeek 1.1 use Data::Dumper;
2 :     use strict;
3 :     use Getopt::Long;
4 :     use FIG;
5 :     my $fig = new FIG;
6 :    
7 :     my $md5s = 0;
8 :     my $out = "";
9 :    
10 :     my $usage = "usage: solid_rectangles_to_solid_families -o OutputFile [-m to get md5s]\n";
11 :     my $rc = GetOptions('m' => \$md5s,
12 :     'o=s' => \$out);
13 :     if ((! $rc) || (! $out)) { print STDERR $usage; exit }
14 :    
15 :     open(OUT,"| sort -T . -k 1 -n > $out") || die "could not open output";
16 :    
17 :     my %seen;
18 :     my $nxt_set = 1;
19 :    
20 :     $/ = "\n//\n";
21 :     while (defined($_ = <STDIN>))
22 :     {
23 :     chomp;
24 :     my @lines = map { ($_ =~ /^\S+\t(\S.*\S)/) ? [split(/\t/,$1)] : () } split(/\n/,$_);
25 :     if (@lines > 1)
26 :     {
27 :     print STDERR "set of ",scalar @lines,"\n";
28 :    
29 :     my $i;
30 :     for ($i=0; ($i < @{$lines[0]}); $i++)
31 :     {
32 :     my @set = map { $_->[$i] } @lines;
33 :     my @set = map { $fig->md5_of_peg($_) } @set;
34 :     my @n = grep { $seen{$_} } @set;
35 :     my $setN = (@n == 0) ? $nxt_set++ : $n[0];
36 :     my %entries = map { ($_ => 1) } @set;
37 :     @set = map { $md5s ? $_ : $fig->pegs_with_md5($_) } keys(%entries);
38 :     @set = sort { $md5s ? ($a cmp $b) : &SeedUtils::by_fig_id($a,$b) } @set;
39 :     foreach $_ (@set)
40 :     {
41 :     print OUT join("\t",($setN,$_)),"\n";
42 :     }
43 :     }
44 :     }
45 :     }
46 :     close(OUT);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3