The BioSequence class
#
The BioSequence class corresponds to the OBITools representation of a nucleic sequence.
Constructor of BioSequence
#
The BioSequence constructor accepts three parameters:
sequence_id: astringcorresponding to the sequenceid. The sequenceidcannot contain white character.dna_sequence: astringrepresenting a nucleic sequence. Thestringis converted to lowercases and must only contain characters corresponding to IUPAC code.definition: this parameter is optional. If present, it corresponds to an unstructured text, used to describe the sequence.
sequence = BioSequence.new("sequence_id","gctagctgtgatgctgatgctagct")
BioSequence Methods #
id : the sequence identifier
#
Extract the sequence identifier from a BioSequence object.
The method doesn’t accept any parameter and returns a string.
sequence = BioSequence.new("sequence_id","gctagctgtgatgctgatgctagct")
print(sequence:id())
sequence_id
A string parameter representing a nucleic sequence can be provided to the
id method. In this case, the id of the BioSequence object is
substituted by the new string. The method does not return anything.
sequence = BioSequence.new("sequence_id","gctagctgtgatgctgatgctagct")
print(sequence:id())
sequence:sequence("new_id")
print(sequence:id())
sequence_id
new_id
sequence : the nucleic sequence
#
When used with no parameter, the method extracts the nucleic sequence itself from the BioSequence object.
In this condition, it returns a string.
sequence = BioSequence.new("sequence_id","gctagctgtgatgctgatgctagct")
print(sequence:sequence())
gctagctgtgatgctgatgctagct
A string parameter representing a nucleic sequence can be provided to the
sequence method. In this case, the current sequence of the object is
substituted by the new string. The method does not return anything.
sequence = BioSequence.new("sequence_id","gctagctgtgatgctgatgctagct")
print(sequence:sequence())
sequence:sequence("cgatctagcta")
print(sequence:sequence())
gctagctgtgatgctgatgctagct
cgatctagcta