[BioRuby-cvs] bioruby/lib/bio/db/embl embl.rb,1.29,1.29.2.1
Jan Aerts
aerts at dev.open-bio.org
Fri Feb 15 04:49:39 UTC 2008
Update of /home/repository/bioruby/bioruby/lib/bio/db/embl
In directory dev.open-bio.org:/tmp/cvs-serv26608/db/embl
Modified Files:
Tag: BRANCH-biohackathon2008
embl.rb
Log Message:
Added functionality to convert a Bio::EMBL object into a full-blown Bio::Sequence object that contains features, references and other additional
information.
Index: embl.rb
===================================================================
RCS file: /home/repository/bioruby/bioruby/lib/bio/db/embl/embl.rb,v
retrieving revision 1.29
retrieving revision 1.29.2.1
diff -C2 -d -r1.29 -r1.29.2.1
*** embl.rb 5 Apr 2007 23:35:40 -0000 1.29
--- embl.rb 15 Feb 2008 04:49:37 -0000 1.29.2.1
***************
*** 3,7 ****
#
#
! # Copyright:: Copyright (C) 2001-2007 Mitsuteru C. Nakao <n at bioruby.org>
# License:: The Ruby License
#
--- 3,9 ----
#
#
! # Copyright:: Copyright (C) 2001-2007
! # Mitsuteru C. Nakao <n at bioruby.org>
! # Jan Aerts <jan.aerts at bbsrc.ac.uk>
# License:: The Ruby License
#
***************
*** 121,124 ****
--- 123,130 ----
alias molecule_type molecule
+ def topology
+ id_line('TOPOLOGY')
+ end
+
# returns DIVISION in the ID line.
# * Bio::EMBL#division -> String
***************
*** 222,227 ****
#
# Bio::EMBLDB#ref
!
!
##
# DR Line; defabases cross-regerence (>=0)
--- 228,233 ----
#
# Bio::EMBLDB#ref
!
!
##
# DR Line; defabases cross-regerence (>=0)
***************
*** 356,366 ****
# bb Line; (blanks) sequence data (>=1)
def seq
! Sequence::NA.new( fetch('').gsub(/ /,'').gsub(/\d+/,'') )
end
alias naseq seq
alias ntseq seq
!
# // Line; termination line (end; 1/entry)
### private methods
--- 362,392 ----
# bb Line; (blanks) sequence data (>=1)
def seq
! Bio::Sequence::NA.new( fetch('').gsub(/ /,'').gsub(/\d+/,'') )
end
alias naseq seq
alias ntseq seq
!
# // Line; termination line (end; 1/entry)
+ def to_biosequence
+ bio_seq = Bio::Sequence.new(self.seq)
+ bio_seq.entry_id = self.entry_id
+ bio_seq.primary_accession = self.accessions[0]
+ bio_seq.secondary_accessions = self.accessions[1,-1]
+ bio_seq.molecule_type = self.molecule_type
+ bio_seq.definition = self.description
+ bio_seq.topology = self.topology
+ bio_seq.date_created = self.dt['created']
+ bio_seq.date_modified = self.dt['updated']
+ bio_seq.division = self.division
+ bio_seq.sequence_version = self.version
+ bio_seq.keywords = self.keywords
+ bio_seq.species = self.os(0)[0]['os'] + ' ' + self.os(0)[0]['name']
+ bio_seq.classification = self.oc
+ bio_seq.references = self.references
+ bio_seq.features = self.ft
+
+ return bio_seq
+ end
### private methods
***************
*** 401,402 ****
--- 427,443 ----
end # module Bio
+
+ if __FILE__ == $0
+ require '../../../bio'
+ require 'yaml'
+
+ prefix = 'FT '
+ indent = prefix + ' ' * 16
+ fwidth = 80 - indent.length
+
+ parser = Bio::FlatFile.auto('/home/aertsj/LocalDocuments/hackathon/aj224122.embl')
+ parser.each do |entry|
+ # entry.ref
+ puts entry.to_biosequence.output(:embl)
+ end
+ end
\ No newline at end of file
More information about the bioruby-cvs
mailing list