bioxml-game/ 40775 765 764 0 7032225065 11643 5ustar sacbioperlbioxml-game/dtd/ 40775 765 764 0 7032225065 12416 5ustar sacbioperlbioxml-game/dtd/GAME.dtd100664 765 764 32612 7027606432 13752 0ustar sacbioperl bioxml-game/README100664 765 764 325 6774060307 12610 0ustar sacbioperlThis repository is for document type definitions describing biological sequence annotations. It also includes tools for manipulating documents that follow these DTDs, some real examples, and related documentation.bioxml-game/examples/ 40775 765 764 0 7032225065 13461 5ustar sacbioperlbioxml-game/examples/DmNotch_pfam_partial.xml100664 765 764 4464 7015333763 20371 0ustar sacbioperl 08/26/1999 hmmpfam 2.1.1 E none Pfam god (and Sean Eddy) knows when it was created 4.1 1015.5 Pfam PF00008 Description EGF-like domain E-value 1.2e-301 N 37 22.6 Motif EGF 62 32 CTSV-GCQNGGTCVTQLN------GKTYCACDSH-----YVGDYC 0 44 CapnnpCsngGtCvntpggssdnfggytCeCppGdyylsytGkrC E-value 0.0091 32.5 Motif EGF 100 35 CNSI-RCQNGGTCQVTFRNG---RPGISCKCPLG-----FDESLC 0 44 CapnnpCsngGtCvntpggssdnfggytCeCppGdyylsytGkrC E-value 1e-05 bioxml-game/tools/ 40775 765 764 0 7032225065 13003 5ustar sacbioperlbioxml-game/tools/Game/ 40775 765 764 0 7032225065 13654 5ustar sacbioperlbioxml-game/tools/Game/Formatter.pm100664 765 764 6360 6765633267 16302 0ustar sacbioperl=head1 NAME Game::Formatter - Handler for Formatter Formats =head1 SYNOPSIS =cut package Game::Formatter; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; use Bio::Root::Object; @ISA = qw(Bio::Root::Object Exporter); =head2 make Title : make Usage : $format = Game::Formatter->make(-file => $filename, -format => 'Format') Function: Returns a new Returns : A Game::Formatter::Handler initialsed with the appropiate format Args : -file => $filename -format => format -fh => filehandle to attach to =cut my $entry = 0; sub make { my ($class,%param) = @_; my ($format); $format = $param{'-format'} || $param{'-FORMAT'}; if( &_load_format_module($format) == 0 ) { return undef; } $format = "Game::Formatter::$format"->new(%param); return $format; } =head2 _load_format_module Title : _load_format_module Usage : *INTERNAL Formatter stuff* Function: Loads up (like use) a module at run time on demand Example : Returns : Args : =cut sub _load_format_module { my ($format) = @_; my ($module,$load,$m); $module = "_SUPER::_initialize; my ($file,$fh, $sf) = $self->_rearrange([qw( FILE FH )], @args, ); if( $file && $fh ) { $self->throw("Providing both a file and a filehandle for reading from - only one please!"); } if( $file ) { $fh = new IO::File; $fh->open(">$file") || $self->throw("Could not open $file for format writing $!"); } # print "Setting filehandle to $fh\n"; if ($fh) { $self->_filehandle($fh); $self->stream(Game::Stream::Filestream->new($fh)); } # set stuff in self from @args return $make; # success - we hope! } =head2 _filehandle Title : _filehandle Usage : $obj->_filehandle($newval) Function: Example : Returns : value of _filehandle Args : newvalue (optional) =cut sub _filehandle { my ($obj,$value) = @_; if( defined $value) { $obj->{'_filehandle'} = $value; } return $obj->{'_filehandle'}; } sub stream { my $self = shift; $self->{_stream} = shift if @_; return $self->{_stream}; } =head2 comp_analysis_out Title : comp_analysis_out Usage : comp_analysis_out($comp_analysis, $stream) Function: transforms a CompAnalysis object to XML Returns : Args : CompAnalysis, Stream =cut sub comp_analysis_out { my $self = shift; $self->throw("this should be defined in the implementation class"); } 1; bioxml-game/tools/Game/ModelBuilder.pm100664 765 764 6066 6765633267 16711 0ustar sacbioperl =head1 NAME Game::ModelBuilder - Handler for ModelBuilder Formats =head1 SYNOPSIS =cut package Game::ModelBuilder; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; use IO::File; use Bio::Root::Object; use Game::Stream::Filestream; @ISA = qw(Bio::Root::Object Exporter); # _initialize is where the heavy stuff will happen when new is called =head2 make Title : make Usage : $format = Game::ModelBuilder->make(-file => $filename, -format => 'Format') Function: Returns a new Returns : A Game::ModelBuilder::Handler initialsed with the appropiate format Args : -file => $filename -format => format -fh => filehandle to attach to =cut my $entry = 0; sub make { my ($class,%param) = @_; my ($format); $format = $param{'-format'} || $param{'-FORMAT'}; if( &_load_format_module($format) == 0 ) { return undef; } $format = "Game::ModelBuilder::$format"->new(%param); return $format; } =head2 _load_format_module Title : _load_format_module Usage : *INTERNAL ModelBuilder stuff* Function: Loads up (like use) a module at run time on demand Example : Returns : Args : =cut sub _load_format_module { my ($format) = @_; my ($module,$load,$m); $module = "_SUPER::_initialize; my ($file,$fh, $sf) = $self->_rearrange([qw( FILE FH )], @args, ); if( $file && $fh ) { $self->throw("Providing both a file and a filehandle for reading from - only one please!"); } if( $file ) { $fh = new IO::File; $fh->open($file) || $self->throw("Could not open $file for format reading $!"); } # print "Setting filehandle to $fh\n"; if ($fh) { $self->_filehandle($fh); $self->stream(Game::Stream::Filestream->new($fh)); } # set stuff in self from @args return $make; # success - we hope! } =head2 _filehandle Title : _filehandle Usage : $obj->_filehandle($newval) Function: Example : Returns : value of _filehandle Args : newvalue (optional) =cut sub _filehandle { my ($obj,$value) = @_; if( defined $value) { $obj->{'_filehandle'} = $value; } return $obj->{'_filehandle'}; } sub stream { my $self = shift; $self->{_stream} = shift if @_; return $self->{_stream}; } 1; bioxml-game/tools/Game/Formatter/ 40775 765 764 0 7032225065 15617 5ustar sacbioperlbioxml-game/tools/Game/Formatter/Embl.pm100664 765 764 1160 6765633267 17152 0ustar sacbioperl =head2 comp_analysis_out Title : comp_analysis_out Usage : comp_analysis_out($comp_analysis, $handler) Function: transforms a CompAnalysis object to EMBL fmt Returns : Args : CompAnalysis, Handler =cut sub comp_analysis_out { my $self = shift; my $comp_analysis = shift; my $handler = shift; } =head2 result_set_out Title : result_set_out Usage : result_set_out($result_set, $handler) Function: transforms a ResultSet object to EMBL fmt Returns : Args : ResultSet, Handler =cut sub result_set_out { my $self = shift; my $result_set = shift; my $handler = shift; } bioxml-game/tools/Game/Formatter/Game.pm100664 765 764 3433 6765633267 17151 0ustar sacbioperlpackage Game::Formatter::Game; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; @ISA = qw(Game::Formatter Exporter); =head2 comp_analysis_out Title : comp_analysis_out Usage : comp_analysis_out($comp_analysis, $stream) Function: transforms a CompAnalysis object to XML Returns : Args : CompAnalysis, Stream =cut sub comp_analysis_out { my $self = shift; my ($comp_analysis, $inserted_text) = $self->_rearrange(['COMP_ANALYSIS', 'TEXT'], @_); my $stream = $self->stream(); $stream->out("seq()."\">"); $stream->out("".$comp_analysis->score().">"); my $result_set; foreach $result_set (@{$comp_analysis->result_set_l()}) { result_set_out($result_set, $stream); } $stream->out(""); } =head2 result_set_out Title : result_set_out Usage : result_set_out($result_set, $stream) Function: transforms a ResultSet object to XML Returns : Args : ResultSet, Stream =cut sub result_set_out { my $self = shift; my ($result_set, $inserted_text) = $self->_rearrange(['RESULT_SET', 'TEXT'], @_); my $stream = $self->stream(); $stream->out(""); $stream->out(""); $stream->out($result_set->score()); $stream->out(""); $stream->out(""); $stream->out($result_set->dbxref()); $stream->out(""); my $type; foreach $type (keys %{$result_set->output_h()}) { $stream->out(""); $stream->out("".$type.""); $stream->out("".$result_set->output_h()->{$type}.""); $stream->out(""); } $stream->out(""); $stream->out($result_set->dbxref()); $stream->out(""); # ... $stream->out(""); } bioxml-game/tools/Game/Model/ 40775 765 764 0 7032225065 14714 5ustar sacbioperlbioxml-game/tools/Game/Model/Annotation.pm100664 765 764 0 6765633267 17412 0ustar sacbioperlbioxml-game/tools/Game/Model/CompAnalysis.pm100664 765 764 2620 6765633267 17774 0ustar sacbioperlpackage Game::Model::CompAnalysis; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; use Bio::Root::Object; @ISA = qw(Bio::Root::Object Exporter); sub _initialize { my $self = shift; my ($seq, $date, $program, $version, $database) = $self->_rearrange(['SEQ', 'DATE', 'PROGRAM', 'VERSION', 'DATABASE'], @_); $self->{_seq} = $seq; $self->{_date} = $date; $self->{_program} = $program; $self->{_version} = $version; $self->{_database} = $database; $self->{result_set_l} = []; } =head2 seq should this be an IDREF or a reference to an actual Seq object? =cut sub seq { my $self = shift; $self->{_seq} = shift if @_; return $self->{_seq}; } =head2 date =cut sub date { my $self = shift; $self->{_date} = shift if @_; return $self->{_date}; } =head2 program =cut sub program { my $self = shift; $self->{_program} = shift if @_; return $self->{_program}; } =head2 version =cut sub version { my $self = shift; $self->{_version} = shift if @_; return $self->{_version}; } =head2 database =cut sub database { my $self = shift; $self->{_database} = shift if @_; return $self->{_database}; } =head2 result_set_l accessor for a ref to a list of ResultSet objects =cut sub result_set_l { my $self = shift; $self->{_result_set_l} = shift if @_; return $self->{_result_set_l}; } 1; bioxml-game/tools/Game/Model/ResultSet.pm100664 765 764 2372 6765633267 17330 0ustar sacbioperl=head1 NAME Game::Model::ResultSet =head2 SYNOPSIS =head2 DESCRIPTION =cut package Game::Model::ResultSet; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; @ISA = qw(Bio::Root::Object Exporter); sub _initialize { my $self = shift; my ($score, $dbxref) = $self->_rearrange(['SCORE', 'DBXREF'], @_); $self->{_score} = $score; $self->{_dbxref} = $dbxref; $self->{_output_h} = {}; $self->{result_l} = []; } =head2 score =cut sub score { my $self = shift; $self->{_score} = shift if @_; return $self->{_score}; } =head2 dbxref =cut sub dbxref { my $self = shift; $self->{_dbxref} = shift if @_; return $self->{_dbxref}; } =head2 output_h this is for weakly typed additional variables xml type output implemented as a hashref (the hash key is the type) - this may not be correct; for instance, we may want two output elements with same "type", or we may want the output elements to be ordered??? this method gets or sets the whole hashref =cut sub output_h { my $self = shift; $self->{_output_h} = shift if @_; return $self->{_output_h}; } =head2 result_l =cut sub result_l { my $self = shift; $self->{_result_l} = shift if @_; return $self->{_result_l}; } 1; bioxml-game/tools/Game/ModelBuilder/ 40775 765 764 0 7032225065 16223 5ustar sacbioperlbioxml-game/tools/Game/ModelBuilder/Blast.pm100664 765 764 4342 6765633267 17751 0ustar sacbioperlpackage Game::ModelBuilder::Blast; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; use Game::Model::ResultSet; use Game::Model::CompAnalysis; @ISA = qw(Game::ModelBuilder Exporter); =head2 next_result_set Title : next_result_set Usage : $result_set = $stream->next_result_set() Function: returns the next ResultSet in the stream Returns : Game::ResultSet object Args : VERY BASIC AT THE MOMENT =cut sub next_result_set { my $self = shift; my $result_set; my $stream = $self->stream(); my $end_of_section = 0; my $section_text = ""; my $line; my $line_no = 0; while (!$end_of_section && ($line = $stream->get_chunk("\n"))) { if ($line =~ /^>/ && $line_no > 0) { $stream->insert($line); # rewind! $end_of_section = 1; } elsif ($line =~ /^PARAMETERS/ && $line_no > 0) { $end_of_section = 1; } else { $section_text.= $line; #... $line_no++; } } # currently does ultra simple parsing - just puts everything in the # xml tag! $result_set = Game::Model::ResultSet->new(-score=>999.88, -dbxref=>"test (not used yet)"); $result_set->output_h()->{unparsed_raw_text} = $section_text; return $result_set; } =head2 next_comp_analysis Title : next_comp_analysis Usage : $comp_analysis = $stream->next_comp_analysis() Function: returns the next CompAnalysis in the stream Returns : Game::CompAnalysis object Args : DOESNT DO MUCH YET =cut sub next_comp_analysis { my $self = shift; my $comp_analysis; my $stream = $self->stream(); my $line; my $end_of_section = 0; my $section_text = ""; while (!$end_of_section && ($line = $stream->get_chunk("\n"))) { if ($line =~ /^>/) { $stream->insert($line); # rewind! $end_of_section = 1; } else { chomp($line); $section_text.= $line; #... } } $comp_analysis = Game::Model::CompAnalysis->new(-seq=>"xxx", -program=>"blast", -database=>"to be parsed..."); # houston we have a problem... # some of CompAnalysis should be parsed BEFORE the ResultSets, # some AFTER # - but we want to allow the API user to go step-by-step return $comp_analysis; } 1; bioxml-game/tools/Game/ModelBuilder/Pfam.pm100664 765 764 0 6765633267 17472 0ustar sacbioperlbioxml-game/tools/Game/Stream/ 40775 765 764 0 7032225065 15107 5ustar sacbioperlbioxml-game/tools/Game/Stream/Filestream.pm100664 765 764 2115 6765633267 17657 0ustar sacbioperlpackage Game::Stream::Filestream; use Exporter; use vars qw($AUTOLOAD @ISA); use strict; use Bio::Root::Object; @ISA = qw(Bio::Root::Object Exporter); sub _initialize { my $self = shift;; $self->SUPER::_initialize(); my ($fh) = $self->_rearrange(['FH'], @_); $self->{_fh} = $fh; $self->{_insert} = ""; $self->{auto_newline} = 1; return $self; } sub out { my $self = shift; my $text = shift; my $fh = $self->{_fh}; print $fh $text; if ($self->{auto_newline}) { print $fh "\n"; } } sub get_chunk { my $self = shift; my $delimiter = shift; if ($self->{_insert}) { my $i =index($self->{_insert}, $delimiter); if ($i > -1) { my $chunk = substr($self->{_insert}, 0, $i+1); $self->{_insert} = substr($self->{_insert}, $i+1); return $chunk; } } my $fh = $self->{_fh}; $/ = $delimiter; my $chunk = <$fh>; if ($self->{_insert}) { $chunk = $self->{_insert}.$chunk; $self->{_insert} = ""; } return $chunk; } sub insert { my $self = shift; my $text = shift; $self->{_insert} .= $text; } 1; bioxml-game/tools/README100664 765 764 260 7024073413 13735 0ustar sacbioperlThese tools are very much in development! Probably not much worthwhile here yet. All perl tools will probably become part of bioperl questions to: cjm@fruitfly.berkeley.edu bioxml-game/tools/scripts/ 40775 765 764 0 7032225065 14472 5ustar sacbioperlbioxml-game/tools/scripts/blast2xml.pl100775 765 764 1160 6765633267 17060 0ustar sacbioperl#!/usr/local/bin/perl -w use strict; use Game::ModelBuilder; use Game::Formatter; my $in_fn = shift @ARGV || die("no inputfile"); my $out_fn = shift @ARGV || die("no outputfile"); my $in = Game::ModelBuilder->make(-file=>$in_fn, '-format'=>"Blast"); my $out = Game::Formatter->make(-file=>$out_fn, '-format'=>"Game"); my $comp_analysis = $in->next_comp_analysis(); # problem - computational analysis includes # the result sets; we either go back to using header/footer #$out->comp_analysis_out($comp_analysis); my $result_set; while ($result_set = $in->next_result_set()) { $out->result_set_out($result_set); }