wub.mappers package

Submodules

wub.mappers.lastal module

class wub.mappers.lastal.LastRecord(score, r_name, r_start, r_aln_len, r_strand, r_len, r_aln, q_name, q_start, q_aln_len, q_strand, q_len, q_aln)

Bases: tuple

Create new instance of LastRecord(score, r_name, r_start, r_aln_len, r_strand, r_len, r_aln, q_name, q_start, q_aln_len, q_strand, q_len, q_aln)

q_aln

Alias for field number 12

q_aln_len

Alias for field number 9

q_len

Alias for field number 11

q_name

Alias for field number 7

q_start

Alias for field number 8

q_strand

Alias for field number 10

r_aln

Alias for field number 6

r_aln_len

Alias for field number 3

r_len

Alias for field number 5

r_name

Alias for field number 1

r_start

Alias for field number 2

r_strand

Alias for field number 4

score

Alias for field number 0

wub.mappers.lastal.check_lastdb_files(ref_dir, name)[source]

Check that all lastdb files with name label exist within directory

Parameters:
  • ref_dir – directory to check for lastdb files
  • name – label to search for e.g. ‘a’ for a.prj
Returns:

list of missing extensions, [] if none missing

wub.mappers.lastal.clean_lastdb_files(ref_dir, name)[source]

Remove lastdb files having prefix name in ref_dir.

Parameters:
  • ref_dir – directory to check for lastdb files
  • name – label to search for e.g. ‘a’ for a.prj
Returns:

None

Return type:

object

wub.mappers.lastal.compare_genomes_lastal(ref_fasta, target_fasta, filter_alns=True, lastal_options=None, cleanup=True)[source]

Compare a refrence set of sequences to a target set os sequences using lastal alignment.

Parameters:
  • ref_fasta – Reference sequence set in fasta format.
  • target_fasta – Target sequence set in fasta format.
  • filter_alns – Filter alignments if True.
  • lastal_options – Options passed to lastal in a dictionary.
  • cleanup – If True then lastal database files will be deleted.
Returns:

A pandas data frame with various per-alignment statistics.

Return type:

DataFrame

wub.mappers.lastal.filter_top_per_query(records)[source]

Filter lastal alignment records keeping the best scoring one per query.

Parameters:records – A collection of LastRecord named tuples.
Returns:A list of LastRecord named tuples.
Return type:list
wub.mappers.lastal.lastal_align(database, query, executable='lastal', **kwargs)[source]

Runs lastal via subprocess.

Parameters:
  • database – database prefix
  • query – filepath for the query file
  • kwargs – -[args] wanted for lastal e.g. v=’’ for verbosity
Returns:

alignment output

wub.mappers.lastal.lastdb(ref_dir, ref_name, ref, executable='lastdb', **kwargs)[source]

Runs lastdb on ref within ref_dir using the label ref_name if any errors thrown during runtime, files are checked for existence if all files accounted for, successful=False but no errors thrown. Otherwise, IOError or CalledProcessError thrown.

Parameters:
  • ref_dir – directory you will find lastdb files in
  • ref_name – name of the lastdb files e.g. a for a.prj..
  • ref – filepath for reference file
  • executable – path/executable for lastdb e.g. ont_lastdb
  • kwargs – any -[arg] wanted see lastdb -h for details
Returns:

True/False is successful with no errors and command run

Raises:

IOError if files don’t exist

Raises:

subprocess.CalledProcessError for errors during runtime

wub.mappers.lastal.parse_lastal(res)[source]

Parse raw lastal output records.

Parameters:res – Raw lastal results.
Returns:Generator of lastal alignment records.
Return type:generator

Module contents