<div dir="ltr"><div>This is with a FASTA input MSA (all sequences the same length with gap characters, and some pairs will have common gaps).</div><div><br></div><div>I have been loading this incrementally so only two sequences were in RAM at any point - and then switched to multiple threads (so at any point with K threads only 2*K sequences were loaded).</div><div><br></div><div>The test case is only about 100MB on disk, 100 sequences each of 1 million base pairs, and takes about a minute or two (multi-threaded laptop).<br></div><div><br></div><div><div>I don't think this will be memory constrained, so working on the entire MSA with a single thread is fine (if faster).<br></div><div><br></div><div>Thank you,</div><div><br></div><div>Peter<br></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Feb 6, 2025 at 10:36 AM Michiel de Hoon <<a href="mailto:mjldehoon@yahoo.com">mjldehoon@yahoo.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:10px"><div></div>
        <div dir="ltr">> <span>I have lots of pairs of pre-aligned sequences (imported from an external MSA file),</span></div><div dir="ltr"><span><br></span></div><div dir="ltr"><span>In which format is your MSA file?</span></div><div dir="ltr"><span><br></span></div><div dir="ltr"><span>-Michiel<br></span></div><div><br></div>
        
        </div><div id="m_8475683859613579565yahoo_quoted_9753999089">
            <div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">
                
                <div>
                        On Thursday, January 30, 2025 at 11:59:33 PM GMT+9, Peter Cock <<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>> wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                
                
                <div><div id="m_8475683859613579565yiv8603226725"><div dir="ltr">Hello all, and Michiel in particular,<br><br>I am wondering if any of the pairwise alignment code in Bio.Align (much of which is written in C for speed) could help with this use case?:<br><br>I have lots of pairs of pre-aligned sequences (imported from an external MSA file), for which I am doing something like this:<br><br>```python<br>def count_matches_etc(query_seq, subject_seq):<br>    assert len(query_seq) == len(subject_seq), "Should be same length"<br>    matches = non_gap_mismatches = either_gapped = both_gapped = 0<br>    for q, s in zip(query_seq, subject_seq, strict=True):<br>        if q == "-" and s == "-":<br>            both_gapped += 1<br>        elif q == "-" or s == "-":<br>            either_gapped += 1<br>        elif q == s:<br>            matches += 1<br>        else:<br>            non_gap_mismatches += 1<br>    assert matches + non_gap_mismatches + either_gapped + both_gapped == len(query_seq)<br>    return matches, non_gap_mismatches, either_gapped, both_gapped<br><br><br># Test case<br>assert (9, 1, 2, 1) == count_matches_etc("ACGTAC-TAC-GT", "AGGT-CGTAC-GT")<br>```<br><br>Sticking with Python that could be optimized (e.g. I am currently using this with sequences of a million base pairs but few gaps), however I have written this example with clarity foremost in mind.<br><div><br></div><div>Thank you,</div><div><br></div>Peter</div>
</div>_______________________________________________<br>Biopython mailing list  -  <a href="mailto:Biopython@biopython.org" target="_blank">Biopython@biopython.org</a><br><a href="https://mailman.open-bio.org/mailman/listinfo/biopython" target="_blank">https://mailman.open-bio.org/mailman/listinfo/biopython</a><br></div>
            </div>
        </div></div></blockquote></div>