choose correct plugin in script.
[sgn.git] / lib / CXGN / Genotype / ParseUpload.pm
blobbae6fafac5aadcdc46a7c027fd81277fe85b4857
1 package CXGN::Genotype::ParseUpload;
3 use Moose;
4 use Data::Dumper;
5 use MooseX::FollowPBP;
6 use Moose::Util::TypeConstraints;
8 with 'MooseX::Object::Pluggable';
11 has 'chado_schema' => (
12 is => 'ro',
13 isa => 'DBIx::Class::Schema',
14 required => 1,
17 has 'filename' => (
18 is => 'ro',
19 isa => 'Str',
20 required => 1,
23 has 'filename_intertek_marker_info' => (
24 is => 'ro',
25 isa => 'Str|Undef',
28 has 'nd_protocol_id' => (
29 is => 'ro',
30 isa => 'Int|Undef',
33 has 'observation_unit_type_name' => ( #Can be accession, plot, plant, tissue_sample
34 isa => 'Str',
35 is => 'ro',
36 required => 1,
39 has 'organism_id' => (
40 isa => 'Int',
41 is => 'ro',
42 required => 0,
45 has 'create_missing_observation_units_as_accessions' => (
46 isa => 'Bool',
47 is => 'ro',
48 default => 0,
51 has 'igd_numbers_included' => (
52 isa => 'Bool',
53 is => 'ro',
54 default => 0,
57 has 'parse_errors' => (
58 is => 'ro',
59 isa => 'HashRef',
60 writer => '_set_parse_errors',
61 reader => 'get_parse_errors',
62 predicate => 'has_parse_errors',
65 has '_parsed_data' => (
66 is => 'ro',
67 isa => 'HashRef',
68 writer => '_set_parsed_data',
69 predicate => '_has_parsed_data',
72 sub parse {
73 my $self = shift;
75 if (!$self->_validate_with_plugin()) {
76 my $errors = $self->get_parse_errors();
77 #print STDERR "\nCould not validate genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
78 return;
81 if (!$self->_parse_with_plugin()) {
82 my $errors = $self->get_parse_errors();
83 #print STDERR "\nCould not parse genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
84 return;
87 if (!$self->_has_parsed_data()) {
88 my $errors = $self->get_parse_errors();
89 #print STDERR "\nNo parsed data for genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
90 return;
91 } else {
92 return $self->_parsed_data();
95 my $errors = $self->get_parse_errors();
96 #print STDERR "\nError parsing genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
97 return;
100 sub parse_with_iterator {
101 my $self = shift;
103 if (!$self->_validate_with_plugin()) {
104 my $errors = $self->get_parse_errors();
105 #print STDERR "\nCould not validate genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
106 return;
109 if (!$self->_parse_with_plugin()) {
110 my $errors = $self->get_parse_errors();
111 #print STDERR "\nCould not parse genotypes file: ".$self->get_filename()."\nError:".Dumper($errors)."\n";
112 return 1;
116 sub next {
117 my $self = shift;
119 return $self->next_genotype();