if not was_high: start = max(i_lo, i - window) if d_segments and start-d_segments[-1][1] < min_gap_length: (start, jumped_end) = d_segments.pop() was_high = True else: if was_high: d_segments.append((start, i)) was_high = False if was_high: d_segments.append((start, i_hi)) return d_segments try: _compare = importVersionedModule('_compare', globals(), (1, 3), "slow Python dotplot") segments_from_diagonal = _compare.segments_from_diagonal except ExpectedImportError: segments_from_diagonal = py_segments_from_diagonal @UI.display_wrap def dotplot(seq1, seq2, window, threshold, min_gap_length=0, band=None, ui=None): """A list of line segments covering the window-mers with identical matches > threshold Gaps of size less than min_gap will be hidden, which saves on line segments. if 'band' is not None then it limits the searched area """ def one_diagonal(dia): segs = segments_from_diagonal(seq1, seq2, window, threshold, min_gap_length, dia) return [((start, start+dia), (end, end+dia)) for (start, end) in segs]
def _importedPyrexAligningModule(name): try: return importVersionedModule(name, globals(), (3, 1), "slow Python alignment implementation") except ExpectedImportError: return None
start = max(i_lo, i - window) if d_segments and start - d_segments[-1][1] < min_gap_length: (start, jumped_end) = d_segments.pop() was_high = True else: if was_high: d_segments.append((start, i)) was_high = False if was_high: d_segments.append((start, i_hi)) return d_segments try: _compare = importVersionedModule('_compare', globals(), (1, 3), "slow Python dotplot") segments_from_diagonal = _compare.segments_from_diagonal except ExpectedImportError: segments_from_diagonal = py_segments_from_diagonal @UI.display_wrap def dotplot(seq1, seq2, window, threshold, min_gap_length=0, band=None, ui=None): """A list of line segments covering the window-mers with identical matches > threshold
numpy.seterr(all='ignore') numerictypes = numpy.core.numerictypes.sctype2char __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2011, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight"] __license__ = "GPL" __version__ = "1.6.0dev" __maintainer__ = "Peter Maxwell" __email__ = "*****@*****.**" __status__ = "Production" try: pyrex = importVersionedModule('_likelihood_tree', globals(), (2, 1), "pure Python/NumPy likelihoodihood tree") except ExpectedImportError: pyrex = None class _LikelihoodTreeEdge(object): def __init__(self, children, edge_name, alignment=None): self.edge_name = edge_name self.alphabet = children[0].alphabet self.comm = None # for MPI M = children[0].shape[-1] for child in children: assert child.shape[-1] == M # Unique positions are unique combos of input positions if alignment is None:
numpy.seterr(all='ignore') numerictypes = numpy.core.numerictypes.sctype2char __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Peter Maxwell", "Rob Knight"] __license__ = "GPL" __version__ = "1.5.3-dev" __maintainer__ = "Peter Maxwell" __email__ = "*****@*****.**" __status__ = "Production" try: pyrex = importVersionedModule('_likelihood_tree', globals(), (2, 1), "pure Python/NumPy likelihoodihood tree") except ExpectedImportError: pyrex = None class _LikelihoodTreeEdge(object): def __init__(self, children, edge_name, alignment=None): self.edge_name = edge_name self.alphabet = children[0].alphabet self.comm = None # for MPI M = children[0].shape[-1] for child in children: assert child.shape[-1] == M # Unique positions are unique combos of input positions if alignment is None:
# in case it needs to be put back in a more runtime way. #numpy.seterr(all='ignore') import warnings from cogent.align.traceback import alignment_traceback from cogent.evolve.likelihood_tree import LikelihoodTreeEdge from indel_positions import leaf2pog from cogent import LoadSeqs from cogent.core.alignment import Aligned from cogent.align.traceback import map_traceback from cogent.util import parallel from cogent.util.modules import importVersionedModule, ExpectedImportError try: pyrex_align_module = importVersionedModule('_pairwise_pogs', globals(), (3, 1), "slow Python alignment implementation") except ExpectedImportError: pyrex_align_module = None try: pyrex_seq_align_module = importVersionedModule('_pairwise_seqs', globals(), (3, 1), "slow Python alignment implementation") except ExpectedImportError: pyrex_seq_align_module = None __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2011, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "GPL" __version__ = "1.6.0dev" __maintainer__ = "Peter Maxwell" __email__ = "*****@*****.**"
"""P matrices for some DNA models can be calculated without going via the intermediate rate matrix Q. A Cython implementation of this calculation can be used when Q is not required, for example during likelihood tree optimisation. Equivalent pure python code is NOT provided because it is typically slower than the rate-matrix based alternative and provides no extra functionality. """ from cogent.evolve.substitution_model import Nucleotide, CalcDefn from cogent.evolve.predicate import MotifChange from cogent.maths.matrix_exponentiation import FastExponentiator import numpy from cogent.util.modules import importVersionedModule, ExpectedImportError try: _solved_models = importVersionedModule('_solved_models', globals(), (1, 0), "only matrix exponentiating DNA models") except ExpectedImportError: _solved_models = None __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2016, The Cogent Project" __credits__ = ["Peter Maxwell"] __license__ = "GPL" __version__ = "1.9" class PredefinedNucleotide(Nucleotide): _default_expm_setting = None # Instead of providing calcExchangeabilityMatrix this subclass overrrides # makeContinuousPsubDefn to bypass the Q / Qd step.
# in case it needs to be put back in a more runtime way. #numpy.seterr(all='ignore') import warnings from cogent.align.traceback import alignment_traceback from cogent.evolve.likelihood_tree import LikelihoodTreeEdge from indel_positions import leaf2pog from cogent import LoadSeqs from cogent.core.alignment import Aligned from cogent.align.traceback import map_traceback from cogent.util import parallel from cogent.util.modules import importVersionedModule, ExpectedImportError try: pyrex_align_module = importVersionedModule('_pairwise_pogs', globals(), (3, 1), "slow Python alignment implementation") except ExpectedImportError: pyrex_align_module = None try: pyrex_seq_align_module = importVersionedModule('_pairwise_seqs', globals(), (3, 1), "slow Python alignment implementation") except ExpectedImportError: pyrex_seq_align_module = None __author__ = "Peter Maxwell" __copyright__ = "Copyright 2007-2012, The Cogent Project" __credits__ = ["Peter Maxwell", "Gavin Huttley", "Rob Knight"] __license__ = "GPL" __version__ = "1.5.3" __maintainer__ = "Peter Maxwell" __email__ = "*****@*****.**"