2 package CXGN
::Dataset
::File
;
5 use File
::Slurp qw
| write_file
|;
8 extends
'CXGN::Dataset';
10 has
'file_name' => ( isa
=> 'Str',
12 default => '/tmp/dataset_file',
15 override
('retrieve_genotypes',
18 my $protocol_id = shift;
19 my $file = shift || $self->file_name()."_genotype.txt";
20 my $genotypes = $self->SUPER::retrieve_genotypes
($protocol_id);
21 my $genotype_string = "";
22 my $genotype_example = $genotypes->[0];
23 foreach my $key (sort keys %{$genotype_example->{genotype_hash
}}) {
24 $genotype_string .= $key."\t";
26 $genotype_string .= "\n";
27 foreach my $element (@
$genotypes) {
28 my $genotype_id = $element->{germplasmDbId
};
29 my $genotype_data_string = "";
30 foreach my $key (sort keys %{$element->{genotype_hash
}}) {
31 my $value = $element->{genotype_hash
}->{$key};
32 my $current_genotype = $value;
33 $genotype_data_string .= $current_genotype."\t";
35 my $s = join "\t", $genotype_id;
36 $genotype_string .= $s."\t".$genotype_data_string."\n";
38 write_file
($file, $genotype_string);
41 # my $genotype_json = JSON::Any->encode($genotypes);
42 # write_file($file, $genotype_json);
46 override
('retrieve_phenotypes',
49 my $file = shift || $self->file_name()."_phenotype.txt";
50 my $phenotypes = $self->SUPER::retrieve_phenotypes
();
51 my $phenotype_string = "";
52 foreach my $line (@
$phenotypes) {
53 my $s = join "\t", @
$line;
54 $phenotype_string .= $s."\n";
56 write_file
($file, $phenotype_string);
60 override
('retrieve_accessions',
63 my $file = shift || $self->file_name()."_accessions.txt";
64 my $accessions = $self->SUPER::retrieve_accessions
();
65 my $accession_json = JSON
::Any
->encode($accessions);
66 write_file
($file, $accession_json);
70 override
('retrieve_plots',
73 my $file = shift || $self->file_name()."_plots.txt";
74 my $plots = $self->SUPER::retrieve_plots
();
75 my $plot_json = JSON
::Any
->encode($plots);
76 write_file
($file, $plot_json);
80 override
('retrieve_trials',
83 my $file = shift || $self->file_name()."_trials.txt";
84 my $trials = $self->SUPER::retrieve_trials
();
85 my $trial_json = JSON
::Any
->encode($trials);
86 write_file
($file, $trial_json);
90 override
('retrieve_traits',
93 my $file = shift || $self->file_name()."_traits.txt";
94 my $traits = $self->SUPER::retrieve_traits
();
95 my $trait_json = JSON
::Any
->encode($traits);
96 write_file
($file, $trait_json);
100 override
('retrieve_years',
103 my $file = shift || $self->file_name()."_years.txt";
104 my $years = $self->SUPER::retrieve_years
();
105 my $year_json = JSON
::Any
->encode($years);
106 write_file
($file, $year_json);