skbio.alignment.AlignPath.from_coordinates#
- classmethod AlignPath.from_coordinates(coords)[source]#
Create an alignment path from an array of segment coordinates.
- Parameters:
- coordsarray_like of int of shape (n_sequences, n_segments)
Array where each value defines the start positions (index) of each segment for each sequence.
- Returns:
- AlignPath
The alignment path created from the given coordinates.
See also
Notes
The input is compatible with the underlying data structure of BioPython’s
Alignment
class [1].References
Examples
>>> import numpy as np >>> from skbio.alignment import AlignPath >>> coordinates = np.array([[0, 1, 1, 3, 4], ... [0, 1, 3, 3, 3], ... [0, 1, 1, 3, 3]]) >>> path = AlignPath.from_coordinates(coordinates) >>> path <AlignPath, sequences: 3, positions: 6, segments: 4>
One can convert a Biopython’s
Alignment
object into a scikit-bio alignment path using this method.>>> from Bio import Align >>> a = Align.PairwiseAligner() >>> res = a.align("GATCGTC", "ATCGCTC") >>> print(res[0]) target 0 GATCG-TC 7 0 -||||-|| 8 query 0 -ATCGCTC 7
>>> coords = res[0].coordinates >>> coords array([[0, 1, 5, 5, 7], [0, 0, 4, 5, 7]])
>>> from skbio.alignment import PairAlignPath >>> path = PairAlignPath.from_coordinates(coords) >>> path <PairAlignPath, positions: 8, segments: 4, CIGAR: '1D4M1I2M'>