2 package CXGN
::Genotype
::SNP
;
12 if ($args->{vcf_string
}) {
13 #print STDERR "Building SNP from vcf_string $args->{vcf_string}...\n";
14 $self->from_vcf_string($args->{vcf_string
});
16 #print STDERR "Counts: ".$self->ref_count().", ".$self->alt_count()."\n";
20 has
'id' => (isa
=> 'Str',
24 has
'format' => ( isa
=> 'Str',
27 has
'vcf_string' => ( isa
=> 'Str',
30 has
'accession' => (isa
=> 'Str',
34 has
'ref_allele' => ( isa
=> 'Str',
38 has
'alt_allele' => ( isa
=> 'Str',
42 has
'ref_count' => ( isa
=> 'Int',
46 has
'alt_count' => ( isa
=> 'Int',
60 if ($self->format()) {
61 @ids = split ":", $self->format();
64 # usual order... but this is just guesswork
65 #print STDERR "(Guessing the format order...)\n";
66 @ids = ( 'GT', 'AD', 'DP', 'GQ', 'PL' );
69 my @values = split /\:/, $raw;
72 for(my $i=0; $i<@ids; $i++) {
73 $fields{$ids[$i]} = $values[$i];
76 #my ($allele, $counts) = split /\:/, $raw;
77 my ($a1, $a2) = ("","");
78 if (!exists($fields{GT
})) {
79 print STDERR
"No allele calls found for snp ".$self->id()."\n";
82 ($a1, $a2) = split /\//, $fields{GT
};
84 $self->ref_allele($a1);
85 $self->alt_allele($a2);
88 if (!exists($fields{AD
})) {
90 #print STDERR "C1: $c1\n";
92 #print STDERR "C2: $c2\n";
95 my @counts = split /\,/, $fields{AD
};
96 # print STDERR "FIELDS: $fields{AD}\n";
98 #print STDERR "Multiple alleles found for SNP ".$self->id()."\n";
100 ($c1, $c2) = @counts;
102 if (!defined($c1)) { $c1=0; }
103 if (!defined($c2)) { $c2=0; }
104 $self->ref_count($c1);
105 $self->alt_count($c2);
108 #if ($self->id() eq "1002:250060174") {
109 #print STDERR $self->id().": ".$fields{GT}.", ".$fields{AD}."\n";
117 my $call_sum_min = shift || 2;
118 my ($c1, $c2) = ($self->ref_count(), $self->alt_count());
119 if ( ($c1 + $c2) < $call_sum_min) {
126 __PACKAGE__
->meta->make_immutable;