[Bioperl-guts-l] bioperl-live/Bio/ClusterIO dbsnp.pm,1.17,1.18
Christopher John Fields
cjfields at dev.open-bio.org
Thu Mar 8 13:40:08 EST 2007
Update of /home/repository/bioperl/bioperl-live/Bio/ClusterIO
In directory dev.open-bio.org:/tmp/cvs-serv16965
Modified Files:
dbsnp.pm
Log Message:
switch to XML::SAX (not heavily tested); this module needs to be heavily refactored per bug 2018
Index: dbsnp.pm
===================================================================
RCS file: /home/repository/bioperl/bioperl-live/Bio/ClusterIO/dbsnp.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** dbsnp.pm 26 Sep 2006 22:03:05 -0000 1.17
--- dbsnp.pm 8 Mar 2007 18:40:06 -0000 1.18
***************
*** 55,69 ****
use Bio::Root::Root;
use Bio::Variation::SNP;
! use XML::Parser::PerlSAX;
! use XML::Handler::Subs;
use Data::Dumper;
use IO::File;
- use vars qw($DTD $DEBUG %MODEMAP %MAPPING);
- $DTD = 'ftp://ftp.ncbi.nih.gov/snp/specs/NSE.dtd';
use base qw(Bio::ClusterIO);
! BEGIN {
! %MAPPING = (
#the ones commented out i haven't written methods for yet... -Allen
'Rs_rsId' => 'id',
--- 55,68 ----
use Bio::Root::Root;
use Bio::Variation::SNP;
! use XML::SAX;
use Data::Dumper;
use IO::File;
+ use Time::HiRes qw(tv_interval gettimeofday);
use base qw(Bio::ClusterIO);
! our $DEBUG = 0;
!
! our %MAPPING = (
#the ones commented out i haven't written methods for yet... -Allen
'Rs_rsId' => 'id',
***************
*** 143,147 ****
#there are lots more, but i don't need them at the moment... -Allen
);
- }
sub _initialize{
--- 142,145 ----
***************
*** 150,155 ****
my ($usetempfile) = $self->_rearrange([qw(TEMPFILE)], at args);
defined $usetempfile && $self->use_tempfile($usetempfile);
! $self->{'_xmlparser'} = new XML::Parser::PerlSAX();
! $DEBUG = 1 if( ! defined $DEBUG && $self->verbose > 0);
}
--- 148,157 ----
my ($usetempfile) = $self->_rearrange([qw(TEMPFILE)], at args);
defined $usetempfile && $self->use_tempfile($usetempfile);
!
! # start up the parser factory
! my $parserfactory = XML::SAX::ParserFactory->parser(
! Handler => $self);
! $self->{'_xmlparser'} = $parserfactory;
! $DEBUG = 1 if( ! defined $DEBUG && $self->verbose > 0);
}
***************
*** 168,171 ****
--- 170,177 ----
#Adapted from Jason's blastxml.pm
###
+
+ # you shouldn't have to preparse this; the XML is well-formed and refers
+ # accurately to a remote DTD/schema
+
sub next_cluster {
my $self = shift;
***************
*** 181,187 ****
while( defined( $_ = $self->_readline ) ){
#skip to beginning of refSNP entry
! if($_ !~ m!<Rs>! && $start){
next;
! } elsif($_ =~ m!<Rs>! && $start){
$start = 0;
}
--- 187,193 ----
while( defined( $_ = $self->_readline ) ){
#skip to beginning of refSNP entry
! if($_ !~ m{<Rs[^>]*>} && $start){
next;
! } elsif($_ =~ m{<Rs[^>]*>} && $start){
$start = 0;
}
***************
*** 195,199 ****
#and stop at the end of the refSNP entry
! last if $_ =~ m!</Rs>!;
}
--- 201,205 ----
#and stop at the end of the refSNP entry
! last if $_ =~ m{</Rs>};
}
***************
*** 283,298 ****
my ($self,$data) = @_;
my $nm = $data->{'Name'};
! my $at = $data->{'Attributes'};
!
if($nm eq 'Ss'){
$self->refsnp->add_subsnp;
return;
}
if(my $type = $MAPPING{$nm}){
if(ref $type eq 'HASH'){
#okay, this is nasty. what can you do?
$self->{will_handle} = (keys %$type)[0];
! my $valkey = (values %$type)[0];
! $self->{last_data} = $at->{$valkey};
} else {
$self->{will_handle} = $type;
--- 289,306 ----
my ($self,$data) = @_;
my $nm = $data->{'Name'};
! my $at = $data->{'Attributes'}->{'{}value'};
!
! #$self->debug(Dumper($at)) if $nm = ;
!
if($nm eq 'Ss'){
$self->refsnp->add_subsnp;
return;
}
+
if(my $type = $MAPPING{$nm}){
if(ref $type eq 'HASH'){
#okay, this is nasty. what can you do?
$self->{will_handle} = (keys %$type)[0];
! $self->{last_data} = $at->{Value};
} else {
$self->{will_handle} = $type;
More information about the Bioperl-guts-l
mailing list