modified: Makefile
[GalaxyCodeBases.git] / perl / etc / crep / merge_crep_anno.pl
blob70a92cb5f5209ba16d0ca82475ee8135d51eb3b1
1 #!/bin/env perl
2 use strict;
3 use warnings;
4 #use IO::Unread qw(unread);
5 use Term::ANSIColor qw(:constants);
6 use Data::Dump qw(ddx);
8 die "Usage: $0 <out> <input1> [input2 ...]\n" if @ARGV < 2;
9 my $out = shift @ARGV;
11 my $psif='./Rice.psi';
13 my (@psid,$tmp,%ANNO,%INPUTIDS);
14 open PSI,'<',$psif or die "Error: $!\n";
15 while (<PSI>) {
16 next if /^#/;
17 $tmp = (split /\t/,$_)[1];
18 push @psid,$tmp;
19 ++$INPUTIDS{$tmp};
20 #print "[$tmp_line]\n";
22 close PSI;
23 $tmp = $#psid + 1;
24 warn GREEN,BOLD,$tmp,RESET," ProbeSets loaded.\n";
26 while (<>) {
27 chomp;
28 my @dat = split /\t/;
29 next unless exists $dat[1];
30 $ANNO{shift @dat} = \@dat;
32 $tmp = (keys %ANNO);
33 warn GREEN,BOLD,$tmp,RESET," ProbeSets Found.\n";
35 if ($tmp < $#psid + 1) {
36 print "Lacking:\n";
37 for (@psid) {
38 unless (exists $ANNO{$_}) {
39 print "[$_]\n";
42 die;
44 if ($tmp > $#psid + 1) {
45 print "More:\n";
46 for (keys %ANNO) {
47 unless (exists $INPUTIDS{$_}) {
48 print "[$_]\n";
53 open O,'>',$out or die "Error: $!\n";
54 for (@psid) {
55 print O join("\t",$_,@{$ANNO{$_}}),"\n";
57 close O;
59 __END__
60 perl merge_crep_anno.pl crep_anno_merged.tsv crep_anno_tsv.all.txt crep_anno_tsv.txt*
61 wc -l crep_anno_merged.tsv