add missing trial type codes
[sgn.git] / bin / combine_dosage_files.pl
blobaa2ef45d0eedb7d0d54d9f572a15a4e41ac4f733
2 use strict;
4 use Data::Dumper;
5 use Getopt::Std;
6 use CXGN::GenotypeIO;
8 our ($opt_r, $opt_o); # -r: fix r headers -o: outfile
9 getopts('ro:');
11 my @files = @ARGV;
13 my @io = ();
14 open(my $OUT, ">", $opt_o) || die "Can't open outfile $opt_o";
16 foreach my $f (@files) {
17 print STDERR "Opening file $f... ";
18 my $gtio = CXGN::GenotypeIO->new( { file => $f, format=>"dosage_transposed", fix_r_headers => $opt_r });
19 push @io, $gtio;
21 print STDERR "Done.\n";
24 my %all_markers;
25 my %all_accs;
27 foreach my $io (@io) {
28 print STDERR "processing file ".$io->plugin->file().".\n";
29 while (my $gt= $io->next()) {
30 my $name = $gt->name();
31 my $markers = $gt->markers();
32 foreach my $m (@$markers) {
33 $all_markers{$m}++;
35 my $scores = $gt->rawscores();
36 #print STDERR Dumper($scores);
37 foreach my $k (keys %$scores) {
38 #print "Adding score $scores->{$k} for marker $k to accession $name...\n";
39 $all_accs{$name}->{$k} = $scores->{$k};
45 foreach my $m (sort keys %all_markers) {
46 print $OUT "\t".$m;
48 print $OUT "\n";
51 foreach my $name (sort keys %all_accs) {
52 print $OUT $name;
53 foreach my $m (sort keys %all_markers) {
54 print $OUT "\t".$all_accs{$name}->{$m};
56 print $OUT "\n";
60 print STDERR "Done.\n";