Bio::S...tedRead(3pm)
π Bio::S...tedRead π
okay bestie, welcome to Bio::S...tedRead(3pm) from the User Contributed Perl Documentation collection β this is the manual for Bio::Seq::SimulatedRead and it's genuinely such a fun one. sit down, grab a strawberry π, we're making fake sequencing reads out of real reference sequences and honestly? iconic.
β¨ NAME β¨
Bio::Seq::SimulatedRead β a read with sequencing errors, taken from a reference sequence. no cap, that's the whole vibe. π§
πΈ SYNOPSIS πΈ
use Bio::Seq::SimulatedRead;
use Bio::PrimarySeq;
# Create a reference sequence
my $genome = Bio::PrimarySeq->new( -id => 'human_chr2',
-seq => 'TAAAAAAACCCCTG',
-desc => 'The human genome' );
# A 10-bp error-free read taken from a genome
my $read = Bio::Seq::SimulatedRead->new(
-reference => $genome , # sequence to generate the read from
-id => 'read001', # read ID
-start => 3 , # start of the read on the genome forward strand
-end => 12 , # end of the read on the genome forward strand
-strand => 1 , # genome strand that the read is on
);
# Display the sequence of the read
print $read->seq."\n";
# Add a tag or MID to the beginning of the read
$read->mid('ACGT');
# Add sequencing errors (error positions are 1-based and relative to the
# error-free MID-containing read)
my $errors = {};
$errors->{'8'}->{'+'} = 'AAA'; # insertion of AAA after residue 8
$errors->{'1'}->{'%'} = 'G'; # substitution of residue 1 by a G
$errors->{'4'}->{'-'} = undef; # deletion of residue 4
$read->errors($errors);
# Display the sequence of the read with errors
print $read->seq."\n";
# String representation of where the read came from and its errors
print $read->desc."\n";
π¦ DESCRIPTION π¦
This object is a simulated read with sequencing errors. You get to hand it a reference sequence to take a read from, the position and orientation of the read on that reference, and the sequencing errors you want generated. it's giving build-a-bear but for reads π
The sequence of the read is automatically calculated based on all that info. By default, the description of the reads contains tracking information and will look like this (Bioperl-style):
reference=human_chr2 start=3 end=12 strand=-1 mid=ACGT errors=1%G,4-,8+AAA description="The human genome"
or Genbank-style:
reference=human_chr2 position=complement(3..12) mid=ACGT errors=1%G,4-,8+AAA description="The human genome"
Creating a simulated read follows these steps β read them in order, bestie, the order is the whole point π«Ά:
1/ Define the read start(), end(), strand() and qual_levels() if you want
quality scores to be generated. Do not change these values once set because
the read will not be updated.
2/ Specify the reference sequence that the read should be taken from. Once
this is done, you have a fully functional read. Do not use the reference()
method again after you have gone to the next step.
3/ Use mid() to input a MID (or tag or barcode) to add to the beginning of the
read. You can change the MID until you go to next step.
4/ Give sequencing error specifications using errors() as the last step. You
can do that as many times as you like, and the read will be updated.
π AUTHOR π
Florent E Angly <florent . angly @ gmail-dot-com>.
Copyright (c) 2011 Florent E Angly.
This library is free software; you can redistribute it under the GNU General Public License version 3.
π new π
- Title :
new - Function : Create a new simulated read object
- Usage :
my $read = Bio::Seq::SimulatedRead->new(
-id => 'read001',
-reference => $seq_obj ,
-errors => $errors ,
-start => 10 ,
-end => 135 ,
-strand => 1 ,
);
- Arguments :
-reference=>Bio::SeqI,Bio::PrimarySeqIobject representing the reference sequence to take the read from. Seereference().-errors=> Hashref representing the position of errors in the read. Seeerrors().-mid=> String of a MID to prepend to the read. Seemid().-track=> Track where the read came from in the read description? Seetrack().-coord_style=> Define what coordinate system to use. Seecoord_style().
All other methods from Bio::LocatableSeq are available. π
- Returns : new
Bio::Seq::SimulatedReadobject
π qual_levels π
- Title :
qual_levels - Function : Get or set the quality scores to give to the read. By default, if your reference sequence does not have quality scores, no quality scores are generated for the simulated read. The generated quality scores are very basic. If a residue is error-free, it gets the quality score defined for good residues. If the residue has an error (is an addition or a mutation), the residue gets the quality score specified for bad residues. Call the
qual_levels()method before using thereference()method. - Usage :
my $qual_levels = $read->qual_levels( ); - Arguments : Array reference containing the quality scores to use for:
- good residues (e.g.
30) - bad residues (e.g.
10)
- good residues (e.g.
- Returns : Array reference containing the quality scores to use.
π reference π
- Title :
reference - Function : Get or set the reference sequence that the read comes from. Once the reference has been set, you have a functional simulated read which supports all the
Bio::LocatableSeqmethods. This method must be called afterqual_levels()but beforemid()orerrors(). - Usage :
my $seq_obj = $read->reference(); - Arguments :
Bio::SeqIorBio::PrimarySeqIobject - Returns :
Bio::SeqIorBio::PrimarySeqIobject
β mid β
- Title :
mid - Function : Get or set a multiplex identifier (or MID, or tag, or barcode) to add to the read. By default, no MID is used. This method must be called after
reference()but beforeerrors(). - Usage :
my $mid = read->mid(); - Arguments : MID sequence string (e.g.
'ACGT') - Returns : MID sequence string
π errors π
- Title :
errors - Function : Get or set the sequencing errors and update the read. By default, no errors are made. This method must be called after the
mid()method. - Usage :
my $errors = $read->errors(); - Arguments : Reference to a hash of the position and nature of sequencing errors. The positions are 1-based relative to the error-free MID-containing read (not relative to the reference sequence). For example:
$errors->{34}->{'%'} = 'T' ; # substitution of residue 34 by a T
$errors->{23}->{'+'} = 'GG' ; # insertion of GG after residue 23
$errors->{45}->{'-'} = undef; # deletion of residue 45
Substitutions and deletions are for a single residue, but additions can be additions of several residues.
An alternative way to specify errors is by using array references instead of scalar for the hash values. This allows one to specify redundant mutations. For example, the case presented above would result in the same read sequence as the example below:
$errors->{34}->{'%'} = ['C', 'T'] ; # substitution by a C and then a T
$errors->{23}->{'+'} = ['G', 'G'] ; # insertion of G and then a G
$errors->{45}->{'-'} = [undef, undef]; # deletion of residue, and again
- Returns : Reference to a hash of the position and nature of sequencing errors.
π§ track π§
- Title :
track - Function : Get or set the tracking status in the read description. By default, tracking is on. This method can be called at any time.
- Usage :
my $track = $read->track(); - Arguments :
1for tracking,0otherwise - Returns :
1for tracking,0otherwise
π«Ά coord_style π«Ά
- Title :
coord_style - Function : When tracking is on, define which 1-based coordinate system to use in the read description:
'bioperl'uses thestart,endandstrandkeywords (default), similarly to the GFF3 format. Example:
start=1 end=10 strand=+1
start=1 end=10 strand=-1
'genbank'does only provide thepositionkeyword. Example:
position=1..10
position=complement(1..10)
- Usage :
my $coord_style = $read->track(); - Arguments :
'bioperl'or'genbank' - Returns :
'bioperl'or'genbank'
and that's the whole page, bestie!! π this beauty ships as perl v5.32.1, dated 2021-08-15, and it lives in the Bio::S...tedRead(3pm) slot of your friendly neighbourhood perl docs. go forth and simulate some reads, you absolute main character πβ¨π
π¦ where this page comes from
- debian bookworm: libbio-perl-perl 1.7.8-1 Β· Perl
- debian trixie: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu jammy: libbio-perl-perl 1.7.8-1 Β· Perl
- ubuntu noble: libbio-perl-perl 1.7.8-1 Β· Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms