NAME

FASTX::Seq - A class for representing a sequence for FASTX::Reader

VERSION

version 1.12.0

SYNOPSIS

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:

seq

The actual sequence, the only mandatory field (string)

name

The sequence identifier, can be omitted (string / undef)

comment

The sequence comment, can be omitted (string / undef)

qual

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");

GLOBAL VARIABLES

$FASTX::Seq::DEFAULT_QUALITY [default: 'I']

Default quality character to use when no quality is provided. Stored in each record as default_quality.

$FASTX::Seq::DEFAULT_LINE_LEN [default: 0]

Default line length for FASTA output. If set to 0, no line break is added. Stored in each record as line_len.

$FASTX::Seq::DEFAULT_OFFSET [default: 33]

Default quality offset. Default is 33, which is the standard for Sanger/Illumina 1.8+. Stored in each record as offset.

NAME

FASTX::Seq - A class for representing a sequence for FASTX::Reader

VERSION

version 1.11.0

MAIN METHODS

new($seq, $name, $comment, $qual)

Create a new instance of FASTX::Seq. The sequence is the only required field.

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):

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,
);

copy()

Create a copy of the current instance.

my $copy = $fastq->copy();

seq()

Get or update the sequence field.

my $seq = $fastq->seq();
$fastq->seq("ATGCTT");

name()

Get or update the sequence field.

my $seq = $fastq->name();
$fastq->name("seq1");

qual()

Get or update the sequence field.

my $seq = $fastq->qual();
$fastq->qual("IIIII");

comment()

Get or update the sequence field.

my $seq = $fastq->comment();
$fastq->comment("len=" . length($fastq->seq()));

offset()

Get or update the sequence field.

$fastq->offset(33);

line_len()

Get or update the sequence field.

$fastq->line_len(33);

default_quality()

Get or update the sequence field.

$fastq->default_quality(33);

len()

Length of the sequence

my $len = $fastq->len();

SEQUENCE MANIPULATION

rev()

Reverse (no complement) the sequence in place.

my $rev = $fastq->rev();

rc()

Reverse and complement the sequence in place (as it's revesible). Supports IUPAC degenerate bases.

my $rc = $fastq->rc();

slice()

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);

translate([genetic_code])

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();

QUALITY

char2qual(char, [offset]])

Convert encoded quality to its integer value. If offset is not provided, will use the default offset.

my $encoded_phred = $fastq->qual2phred("!", 33);

qual2char(int, [offset])

Convert integer quality score to encoded phred scores. If offset is not provided, will use the default offset.

my $encoded_phred = $fastq->qual2phred("!", 33);

qualities()

Returns an array of quality values for each base of the record.

my @qualities = $fastq->qualities();

min_qual()

Return the lowest quality score in the record.

my @qualities = $fastq->min_qual();

max_qual()

Return the lowest quality score in the record.

my @qualities = $fastq->max_qual();

trim_after(quality_integer)

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_until(quality_integer)

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);

VALIDATION AND STRING GENERATION

string()

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();

as_string()

Alias to string()

asfasta([length]])

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();

asfastq()

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();

as_fasta()

Alias to asfasta()

as_fastq()

Alias to asfastq()

is_fasta()

Return true if the record has not a quality value stored (FASTA)

if ( $seq->is_fasta() ) {
    ...
}

is_fastq()

Return true if the record has a quality value stored (FASTQ)

if ( $seq->is_fastq() ) {
    ...
}

AUTHOR

Andrea Telatin <andrea@telatin.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Andrea Telatin.

This is free software, licensed under:

The MIT (X11) License

AUTHOR

Andrea Telatin <andrea@telatin.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Andrea Telatin.

This is free software, licensed under:

The MIT (X11) License