diff --git a/modules/Bio/EnsEMBL/Lite/SNPAdaptor.pm b/modules/Bio/EnsEMBL/Lite/SNPAdaptor.pm index 168fb3cb457d1d4f0b7fde2f27833b1e22daf545..0b73480d9db1821ac6d26789d5b3e9e0f6bdc442 100644 --- a/modules/Bio/EnsEMBL/Lite/SNPAdaptor.pm +++ b/modules/Bio/EnsEMBL/Lite/SNPAdaptor.pm @@ -84,7 +84,10 @@ sub fetch_all_by_Slice { } #create a snp object through a fast (hacky) constructor - my $snp = Bio::EnsEMBL::SNP->new_fast( + my $STATUS = $arrayref->[6]; + $STATUS =~s/-/ /; + $STATUS = ( $STATUS && $STATUS ne 'no info' ) ? "proven $STATUS" : 'suspected'; + my $snp = Bio::EnsEMBL::SNP->new_fast( { 'dbID' => $arrayref->[0], '_gsf_start' => $arrayref->[1] - $slice_start + 1, '_gsf_end' => $arrayref->[2] - $slice_start + 1, @@ -93,11 +96,13 @@ sub fetch_all_by_Slice { '_type' => $arrayref->[4], '_range_type' => $arrayref->[5], '_validated' => $arrayref->[6], - 'alleles' => $arrayref->[7], + 'status' => $STATUS, + 'alleles' => $arrayref->[7], '_ambiguity_code' => $arrayref->[10], '_snpclass' => $arrayref->[8], '_mapweight' => $arrayref->[9], - '_source_tag' => $arrayref->[11], + '_source' => $arrayref->[11], + '_source_tag' => $arrayref->[11], 'link' => \@links }); push @snps, $snp; } @@ -105,5 +110,63 @@ sub fetch_all_by_Slice { return \@snps; } +sub fetch_attributes_only{ + my $self = shift; + + my $refsnp_id = shift; + my $source = shift || 'dbSNP'; + + my $WHERE = $source eq 'dbSNP' ? "id_refsnp = ? and source='dbSNP'" : "id_ano=? and source='non-dbSNP'"; + my %SNPS = qw( 12 dbSNP 13 WI 14 HGBASE 15 TSC-CSHL 16 ANO ); + my $QUERY = "select internal_id, chr_start, chr_end, chr_strand, type, range_type, + validated, alleles, snpclass, mapweight, ambiguity, source, + id_refsnp, id_wi, id_hgbase, id_tsc, id_ano, chr_name + FROM snp + WHERE $WHERE"; + + my $sth = $self->prepare( $QUERY ); + eval { $sth->execute($refsnp_id);}; + return [] if $@; + my @snps = (); + + my %link_hash; + my $link; + + while(my $arrayref = $sth->fetchrow_arrayref()) { + my @links = (); + foreach( sort keys %SNPS ) { + my $V = $arrayref->[ $_ ]; + if( $V && $V ne '' ) { + unless($link = $link_hash{"$SNPS{$_}:$V"}) { + $link_hash{"$SNPS{$_}:$V"} = $link = Bio::EnsEMBL::DBEntry->new_fast( {'_dbname' => $SNPS{$_}, '_primary_id' => $V }); + } + push @links, $link; + } + } + + #create a snp object through a fast (hacky) constructor + my $STATUS = $arrayref->[6]; + $STATUS =~s/-/ /; + $STATUS = ( $STATUS && $STATUS ne 'no info' ) ? "proven $STATUS" : 'suspected'; + my $snp = Bio::EnsEMBL::SNP->new_fast( + { 'dbID' => $arrayref->[0], + '_snp_strand' => $arrayref->[3], + '_gsf_score' => 1, + '_type' => $arrayref->[4], + '_range_type' => $arrayref->[5], + '_validated' => $arrayref->[6], + 'status' => $STATUS, + 'alleles' => $arrayref->[7], + '_ambiguity_code' => $arrayref->[10], + '_snpclass' => $arrayref->[8], + '_mapweight' => $arrayref->[9], + '_source' => $arrayref->[11], + '_source_tag' => $arrayref->[11], + 'link' => \@links }); + return $snp; + } + return undef; +} + 1;