[BioRuby] Bio::GenBank
Naohisa GOTO
ngoto at gen-info.osaka-u.ac.jp
Sat Nov 28 09:00:01 UTC 2009
Hello Jose,
On Fri, 27 Nov 2009 18:55:38 -0800
Jose Otero <josejotero at gmail.com> wrote:
> Hello all,
> I'm new to BioRUby and I am trying to adapt the BioGenbank class to store
> information of my plasmid database.
> Question 1: Does anybody know how to insert a nucleic acid sequence as the
> value to 'sequence' in the @data object?
> Placing in inoformation as Bio::Feature::Qualifier objects is easy, as is
> inserting Bio::Locus information. But I can't figure how to insert the
> sequence data.
Once an object of the Bio::GenBank class is created, each data stored
in the object is intended to be read-only, though modification is not
explicitly prohibited. This is because the class is designed for
efficient parsing of the GenBank formatted text, and it is technically
not easy to achieve both efficient parsing and flexible modification.
(This is also applied to most parser classes, e.g. Bio::EMBL, Bio::SPTR,
etc.)
In your case, using Bio::Sequence seems the best way. After converted
to Bio::Sequence object, from a Bio::GenBank object, it can be freely
modified.
# Assume str contains GenBank formatted text as String.
#
# Creating a new Bio::GenBank object.
gb = Bio::GenBank.new(str)
# Converting to Bio::Sequence object
s = gb.to_biosequence
# Modifying the sequence.
#
# Note that other attributes, such as features and references
# (which depend on locations on the sequence) are kept unchanged.
# Relocation of the features, references, etc. is relied on the
# user.
#
s.seq = 'atgc' * 10 + s.seq
# Text formatting as the GenBank format.
puts s.output(:genbank)
Creating a new Bio::Sequence object from scratch, giving definition,
accessions, keywords, references, features, etc., and getting
GenBank-formatted text can also be done.
> Question 2: Has anybody ever changed the data from a BioGenbank object and
> save the altered file? This would be very interesting for my plasmid
> database.
As described above, Bio::Sequence#output can be used. The method returns
formatted text as String, and you can easily write it to a file.
> Thanks for the help.
> JO
Naohisa Goto
ngoto at gen-info.osaka-u.ac.jp / ng at bioruby.org
More information about the BioRuby
mailing list