Skip to content

Commit

Permalink
Finished sequence docstrings. Fixed tests and refactoring consequences.
Browse files Browse the repository at this point in the history
  • Loading branch information
ODiogoSilva committed Jun 5, 2017
1 parent a7c38e1 commit f085b02
Show file tree
Hide file tree
Showing 10 changed files with 513 additions and 388 deletions.
7 changes: 3 additions & 4 deletions trifusion/TriSeq.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ def main_parser(arg, alignment_list):
if arg.contain_filter:
print_col("Filtering alignment(s) including a taxa group", GREEN,
quiet=arg.quiet)
alignments.filter_by_taxa("Contain", arg.contain_filter, pbar=pbar)
alignments.filter_by_taxa(arg.contain_filter, "Contain", pbar=pbar)

# Filter by alignments that exclude taxa
if arg.exclude_filter:
print_col("Filtering alignments excluding a taxa group", GREEN,
quiet=arg.quiet)
alignments.filter_by_taxa("Exclude", arg.exclude_filter, pbar=pbar)
alignments.filter_by_taxa(arg.exclude_filter, "Exclude", pbar=pbar)

# Filter by codon position
if arg.codon_filter:
Expand Down Expand Up @@ -248,8 +248,7 @@ def main_parser(arg, alignment_list):
# Concatenation
if not arg.conversion and not arg.reverse and not arg.consensus:
print_col("Concatenating", GREEN, quiet=arg.quiet)
alignments = alignments.concatenate(alignment_name=os.path.basename(
outfile), pbar=pbar)
alignments = alignments.concatenate(pbar=pbar)

# Concatenate zorro files
if arg.zorro:
Expand Down
7 changes: 0 additions & 7 deletions trifusion/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4571,8 +4571,6 @@ def popup_info(self, value):
self.active_file_inf["aln_format"]
content.ids.seq_type.text = "%s" % \
self.active_file_inf["seq_type"]
content.ids.is_aln.text = "%s" % \
self.active_file_inf["is_aln"]
content.ids.seq_size.text = "%s" % \
self.active_file_inf["aln_len"]
content.ids.n_taxa.text = "%s" % \
Expand Down Expand Up @@ -10589,8 +10587,6 @@ def get_file_information(self, file_name=None, mode="alignment"):
- seq_type: The sequence type. If DNA, RNA, Protein.
- n_taxa: Number of taxa
- aln_len: Length of the alignment
- is_aln: If the input file is in alignment format of
non-aligned sequence set format
- model: The model of sequence evolution, if applicable.
This is
usually only present on Nexus input format
Expand Down Expand Up @@ -10619,9 +10615,6 @@ def get_file_information(self, file_name=None, mode="alignment"):
file_inf["n_taxa"] = len([x for x in
aln.taxa_list if x in self.active_taxa_list])

# Get if is alignment
file_inf["is_aln"] = str(aln.is_alignment)

# Get length of largest sequence if not aligned, or
# alignment length
file_inf["aln_len"] = aln.locus_length
Expand Down
10 changes: 4 additions & 6 deletions trifusion/data/resources/background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def load_proc(aln_list, file_list, nm, queue):
try:
if aln_list:
aln_list.add_alignment_files(file_list,
shared_namespace=nm)
ns=nm)
aln_obj = aln_list
else:
aln_obj = AlignmentList(file_list, shared_namespace=nm)
Expand Down Expand Up @@ -410,7 +410,7 @@ def filter_aln(aln, table_out="_filter"):
# Get taxa list from taxa groups
ns.main_msg = "Filter (by taxa)"
taxa_list = taxa_groups[taxa_filter_settings[1]]
aln.filter_by_taxa(taxa_filter_settings[0], taxa_list, ns=ns)
aln.filter_by_taxa(taxa_list, taxa_filter_settings[0], ns=ns)

# Filter codon positions
if secondary_options["codon_filter"]:
Expand Down Expand Up @@ -470,8 +470,7 @@ def concatenation(aln, table_in=""):
zorro_data = data.Zorro(aln, zorro_suffix)
zorro_data.write_to_file(output_file)

aln = aln.concatenate(alignment_name=basename(output_file),
table_in=table_in, ns=ns)
aln = aln.concatenate(table_in=table_in, ns=ns)

# Sets the single alignment to True, for other method to be aware of
# this
Expand Down Expand Up @@ -793,8 +792,7 @@ def writer(aln, filename=None, suffix_str="", conv_suffix="",
table_out=suffix[1:])
if main_operations["concatenation"]:
ns.main_msg = "Concatenation"
main_aln = aln_object.concatenate(table_in=suffix[1:],
ns=ns)
main_aln = aln_object.concatenate(ns=ns)

ns.main_msg = "Collapse"
main_aln.collapse(haplotype_name=hap_prefix,
Expand Down
20 changes: 10 additions & 10 deletions trifusion/process/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@


class CleanUp(object):
"""Decorator class that handles temporary data for TriSeq and TriStats
"""Decorator class that handles temporary data for TriSeq and TriStats.
This decorator class wraps the main execution functions of TriSeq and
TriStats programs. The __init__ requires only the function reference,
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(self, func):
self.idx = 0 if self.func.__name__ == "main_parser" else 2

def __call__(self, *args):
"""Wraps the call of `func`
"""Wraps the call of `func`.
When the main `func` is called, this code is wrapped around its
execution. This mainly ensures that the temporary data stored in
Expand Down Expand Up @@ -165,7 +165,7 @@ def __call__(self, *args):


def merger(ranges):
"""Generator that merges continuous ranges of tuples in a list
"""Generator that merges continuous ranges of tuples in a list.
Parameters
----------
Expand Down Expand Up @@ -213,7 +213,7 @@ def has_colours(stream):


def print_col(text, color, i=0, quiet=False):
"""Custom print function for terminal updates of CLI programs
"""Custom print function for terminal updates of CLI programs.
This print function homogenizes the progress logging of all CLI programs
while providing some freedom on the formatting of the progress message,
Expand Down Expand Up @@ -261,7 +261,7 @@ def print_col(text, color, i=0, quiet=False):
class Base(object):

def autofinder(self, reference_file):
"""Autodetects format, missing data symbol and sequence type
"""Autodetects format, missing data symbol and sequence type.
Attempts to find the file format, missing data symbol and sequence
type from a reference file. Due to performance reasons, this function
Expand Down Expand Up @@ -393,7 +393,7 @@ def autofinder(self, reference_file):
@staticmethod
def get_loci_taxa(loci_file):
"""
Get the list of taxa from a .loci file
Get the list of taxa from a .loci file.
This is required prior to parsing the alignment in order to
correctly add missing data when certain taxa are not present in
Expand Down Expand Up @@ -429,7 +429,7 @@ def get_loci_taxa(loci_file):
@staticmethod
def guess_code(sequence):
"""
Guess the sequence type, i.e. protein
Guess the sequence type, i.e. protein.
Guesses the code of the provided `sequence`, that is, if it is a
DNA or Protein sequence based on the first sequence of
Expand Down Expand Up @@ -498,7 +498,7 @@ def guess_code(sequence):
@staticmethod
def rm_illegal(taxon_string):
"""
Removes illegal characters from taxon name
Removes illegal characters from taxon name.
The illegal characters are defined in the `illegal_chars`
variable
Expand Down Expand Up @@ -526,7 +526,7 @@ def rm_illegal(taxon_string):
@staticmethod
def duplicate_taxa(taxa_list):
"""
Identified duplicate items in a list
Identified duplicate items in a list.
Used to detect, for instance, duplicated taxa in the Alignment object
Expand All @@ -549,7 +549,7 @@ def duplicate_taxa(taxa_list):
@staticmethod
def read_basic_csv(file_handle):
"""
Reads a basic CSV into a list
Reads a basic CSV into a list.
Parses a simples CSV file with only one column and one
or more lines while stripping whitespace.
Expand Down
Loading

0 comments on commit f085b02

Please sign in to comment.