add trial design store subclasses.
[sgn.git] / lib / CXGN / Bulk / Converter.pm
blob7253a276581f00b8325067bb13e4aa335511b3a0
2 use strict;
4 package CXGN::Bulk::Converter;
6 use base 'CXGN::Bulk';
7 use File::Slurp;
9 our %solyc_conversion_hash;
11 sub process_parameters {
12 my $self = shift;
13 $self->{output_fields} = [ 'Input', 'Output' ];
15 my @ids = split /\s+/, $self->{ids};
17 $self->{ids} = \@ids;
19 if (@ids) {
20 return 1;
22 else {
23 return 0;
27 sub process_ids {
28 my $self = shift;
30 if (!%solyc_conversion_hash) {
31 $self->get_hash();
34 $self->{query_start_time} = time();
35 my ($dump_fh, $notfound_fh) = $self->create_dumpfile();
36 my @not_found = ();
37 foreach my $id (@{$self->{ids}}) {
38 print STDERR "Converting $id to $solyc_conversion_hash{uc($id)}\n";
39 if (exists($solyc_conversion_hash{uc($id)})) {
40 print $dump_fh "$id\t$solyc_conversion_hash{uc($id)}\n";
42 else {
43 print $notfound_fh "$id\t(not found)\n";
46 close($dump_fh);
47 close($notfound_fh);
48 $self->{query_time} = time() - $self -> {query_start_time};
51 sub get_hash {
52 my $self = shift;
54 print STDERR "Generating hash... ";
56 my @conversion = ();
57 foreach my $file (@{$self->{solyc_conversion_files}}) {
58 print STDERR "(processing $file) ";
59 my @lines = read_file($file);
60 @conversion = (@conversion, @lines);
63 foreach my $entry (@conversion) {
64 my @fields = split /\t/, $entry;
65 $solyc_conversion_hash{uc($fields[0])} = $fields[1];
68 print STDERR "Done.\n";