Result#

ScoreResult#

class pyopal.ScoreResult#

The results of a search in score mode.

__init__(target_index, score)#

Create a new score result.

score#

The score of the alignment.

Type:

int

target_index#

The index of the target in the database.

Type:

int

EndResult#

class pyopal.EndResult(ScoreResult)#

The results of a search in end mode.

__init__(target_index, score, query_end, target_end)#

Create a new end result.

query_end#

The coordinate where the alignment ends in the query.

Type:

int

score#

The score of the alignment.

Type:

int

target_end#

The coordinate where the alignment ends in the target.

Type:

int

target_index#

The index of the target in the database.

Type:

int

FullResult#

class pyopal.FullResult(EndResult)#

The results of a search in full mode.

__init__(target_index, score, query_end, target_end, query_start, target_start, query_length, target_length, alignment)#

Create a new full result.

cigar()#

Create a CIGAR string representing the alignment.

Returns:

str – A CIGAR string in SAM format describing the alignment.

Example

>>> aligner = Aligner()
>>> db = Database(["AACCGCTG"])
>>> hit = aligner.align("ACCTCG", db, mode="full", algorithm="nw")[0]
>>> hit.cigar()
'1D5M1D1M'
coverage(reference='query')#

Compute the coverage of the alignment.

Parameters:

reference (str) – The reference sequence to take to compute the coverage: either query or target.

Returns:

float – The coverage of the alignment against the reference, as a fraction (between 0 and 1).

Example

If we align the test sequences from the Opal dataset with Needleman-Wunsch, we get the following alignment:

T: AACCGCTG (0 - 7)
Q: -ACCTC-G (0 - 5)

The query coverage will be 100%, but the target coverage will only be 87.5%, since the first letter of the target is not covered by the alignment:

>>> aligner = Aligner()
>>> db = Database(["AACCGCTG"])
>>> hit = aligner.align("ACCTCG", db, mode="full", algorithm="nw")[0]
>>> hit.coverage("query")
1.0
>>> hit.coverage("target")
0.875

Added in version 0.2.0.

identity()#

Compute the identity of the alignment.

Returns:

float – The identity of the alignment as a fraction (between 0 and 1).

alignment#

A string used by Opal to encode alignments.

Type:

str

query_end#

The coordinate where the alignment ends in the query.

Type:

int

query_length#

The complete length of the query sequence.

Added in version 0.2.0.

Type:

int

query_start#

The coordinate where the alignment starts in the query.

Type:

int

score#

The score of the alignment.

Type:

int

target_end#

The coordinate where the alignment ends in the target.

Type:

int

target_index#

The index of the target in the database.

Type:

int

target_length#

The complete length of the target sequence.

Added in version 0.2.0.

Type:

int

target_start#

The coordinate where the alignment starts in the target.

Type:

int