[BioRuby-cvs] bioruby/lib/bio/db/genbank genbank.rb, 0.40.2.3, 0.40.2.4
Naohisa Goto
ngoto at dev.open-bio.org
Tue Jun 17 15:56:20 UTC 2008
Update of /home/repository/bioruby/bioruby/lib/bio/db/genbank
In directory dev.open-bio.org:/tmp/cvs-serv21173/lib/bio/db/genbank
Modified Files:
Tag: BRANCH-biohackathon2008
genbank.rb
Log Message:
* Bio::GenBank#to_biosequence is changed to imporve support of sequence output
and data exchange.
* Bio::GenBank#date_created is added. It returns Date object.
Index: genbank.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/genbank/genbank.rb,v
retrieving revision 0.40.2.3
retrieving revision 0.40.2.4
diff -C2 -d -r0.40.2.3 -r0.40.2.4
*** genbank.rb 4 Mar 2008 09:22:35 -0000 0.40.2.3
--- genbank.rb 17 Jun 2008 15:56:18 -0000 0.40.2.4
***************
*** 8,13 ****
--- 8,16 ----
#
+ require 'date'
require 'bio/db'
require 'bio/db/genbank/common'
+ require 'bio/sequence'
+ require 'bio/sequence/dblink'
module Bio
***************
*** 122,129 ****
--- 125,142 ----
alias nalen length
+ # (obsolete???) length of the sequence
def seq_len
seq.length
end
+ # modified date. Returns Date object, String or nil.
+ def date_modified
+ begin
+ Date.parse(self.date)
+ rescue ArgumentError, TypeError, NoMethodError, NameError
+ self.date
+ end
+ end
+
# converts Bio::GenBank to Bio::Sequence
# ---
***************
*** 132,135 ****
--- 145,156 ----
def to_biosequence
sequence = Bio::Sequence.new(seq)
+
+ sequence.id_namespace =
+ if /\_/ =~ self.accession.to_s then
+ 'RefSeq'
+ else
+ 'GenBank'
+ end
+
sequence.entry_id = self.entry_id
***************
*** 137,147 ****
sequence.secondary_accessions = self.accessions - [ self.accession ]
sequence.molecule_type = self.natype
sequence.division = self.division
sequence.topology = self.circular
sequence.sequence_version = self.version
#sequence.date_created = nil #????
! sequence.date_modified = self.date
sequence.definition = self.definition
--- 158,177 ----
sequence.secondary_accessions = self.accessions - [ self.accession ]
+ if /GI\:(.+)/ =~ self.gi.to_s then
+ sequence.other_seqids = [ Bio::Sequence::DBLink.new('GI', $1) ]
+ end
+
sequence.molecule_type = self.natype
sequence.division = self.division
sequence.topology = self.circular
+ sequence.strandedness = case self.strand.to_s.downcase;
+ when 'ss-'; 'single';
+ when 'ds-'; 'double';
+ when 'ms-'; 'mixed';
+ else nil; end
sequence.sequence_version = self.version
#sequence.date_created = nil #????
! sequence.date_modified = date_modified
sequence.definition = self.definition
***************
*** 149,153 ****
sequence.species = self.organism
sequence.classification = self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/)
! #sequence.organnella = nil # not used
sequence.comments = self.comment
sequence.references = self.references
--- 179,183 ----
sequence.species = self.organism
sequence.classification = self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/)
! #sequence.organelle = nil # yet unsupported
sequence.comments = self.comment
sequence.references = self.references
More information about the bioruby-cvs
mailing list