FASTX::Seq - A class for representing a sequence for FASTX::Reader
version 1.12.0
A sequence object supported from FASTX::Reader structured as a BioX::Seq record, but keeping the attribute names as the scalar natively provided by FASTX::Reader. Order of arguments matters:
FASTX::Reader
BioX::Seq
The actual sequence, the only mandatory field (string)
The sequence identifier, can be omitted (string / undef)
The sequence comment, can be omitted (string / undef)
The sequence quality, if provided its length must match the sequence one (string / undef)
use FASTX::Seq; my $fastq = new($seq, $name, $comment, $qual); my $fasta = new($seq, $name, $comment); my $barseq = new("ATGC"); # Change attribute $fastq->seq("ATGCTT");
$FASTX::Seq::DEFAULT_QUALITY
Default quality character to use when no quality is provided. Stored in each record as default_quality.
default_quality
$FASTX::Seq::DEFAULT_LINE_LEN
Default line length for FASTA output. If set to 0, no line break is added. Stored in each record as line_len.
line_len
$FASTX::Seq::DEFAULT_OFFSET
Default quality offset. Default is 33, which is the standard for Sanger/Illumina 1.8+. Stored in each record as offset.
offset
version 1.11.0
Create a new instance of FASTX::Seq. The sequence is the only required field.
FASTX::Seq
Positional arguments (order matters, only the first is mandatory, but comment must be undef if qual is not provided):
my $record = FASTX::Seq->new($seq, $name, $comment, $qual);
Named arguments (order does not matter, only -seq is mandatory, other can be omitted):
-seq
my $fastq_record = FASTX::Seq->new( -seq => "CACCA", # -sequence is also valid -name => $name, # -id is also valid -comment => $comment, -qual => "IFIGH", # -quality is also valid -offset => 33, -line_len => $line_len, -default_quality => $default_quality, );
Create a copy of the current instance.
my $copy = $fastq->copy();
Get or update the sequence field.
my $seq = $fastq->seq(); $fastq->seq("ATGCTT");
my $seq = $fastq->name(); $fastq->name("seq1");
my $seq = $fastq->qual(); $fastq->qual("IIIII");
my $seq = $fastq->comment(); $fastq->comment("len=" . length($fastq->seq()));
$fastq->offset(33);
$fastq->line_len(33);
$fastq->default_quality(33);
Length of the sequence
my $len = $fastq->len();
Reverse (no complement) the sequence in place.
my $rev = $fastq->rev();
Reverse and complement the sequence in place (as it's revesible). Supports IUPAC degenerate bases.
my $rc = $fastq->rc();
Retrieve a slice of the sequence (from, length), as perl's substr. The change is not in place, will return a new object.
my $slice = $fastq->slice(0, 200);
Return the sequence as translated protein sequence. Optional artument is the NCBI Genetic code:
my $seq = FASTX::Seq->new( -seq => 'ATGATG', -id => 'seq1', ); my $orf = $seq->translate(11); say $orf->seq();
Convert encoded quality to its integer value. If offset is not provided, will use the default offset.
my $encoded_phred = $fastq->qual2phred("!", 33);
Convert integer quality score to encoded phred scores. If offset is not provided, will use the default offset.
Returns an array of quality values for each base of the record.
my @qualities = $fastq->qualities();
Return the lowest quality score in the record.
my @qualities = $fastq->min_qual();
my @qualities = $fastq->max_qual();
Trim the record in place after the first base with a quality score lower or equal than the provided integer.
$fastq->trim_after(20);
Trim the record in place up to the the first base with a quality score higher or equal than the provided integer.
$fastq->trim_until(20);
Return the sequence as a string. If arguments are provided, they will be treated as FASTA or FASTQ specific according to the record format.
print $seq->string();
Alias to string()
Return the sequence as a FASTA string. If the length is provided, the sequence will be split into lines of that length.
my $fasta = $seq->asfasta();
Return the sequence as a FASTQ string. Will use a dummy fixed value quality if the sequence didnt have a quality string. Provide an character to use it as quality value, will override the record quality, if it has one.
my $fasta = $seq->asfastq();
Alias to asfasta()
Alias to asfastq()
Return true if the record has not a quality value stored (FASTA)
if ( $seq->is_fasta() ) { ... }
Return true if the record has a quality value stored (FASTQ)
if ( $seq->is_fastq() ) { ... }
Andrea Telatin <andrea@telatin.com>
This software is Copyright (c) 2019 by Andrea Telatin.
This is free software, licensed under:
The MIT (X11) License
To install FASTX::Reader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FASTX::Reader
CPAN shell
perl -MCPAN -e shell install FASTX::Reader
For more information on module installation, please visit the detailed CPAN module installation guide.