Skip to content

Commit

Permalink
debug bp seq
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Jul 21, 2024
1 parent d647955 commit 318d364
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions jcvi/formats/maf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from .base import BaseFile, logger


FLANK = 60


class Maf(BaseFile, dict):
def __init__(self, filename, index=False):
super().__init__(filename)
Expand Down Expand Up @@ -119,26 +122,29 @@ def breakpoints(args):
logger.info("Total alignments: %d", len(filtered_msa))

final = []
# Load the sequences
ar = next(SeqIO.parse(a_fasta, "fasta"))
br = next(SeqIO.parse(b_fasta, "fasta"))
for bp in bps:
i = bisect(filtered_msa, (bp,))
_, arec, brec = filtered_msa[i]
logger.info("Breakpoint at %d")
logger.info("%s", arec)
logger.info("%s", brec)
assert len(arec) == len(brec)
# Find the midpoint, safe to crossover there
midpoint = len(arec) // 2
aseq = arec.seq[:midpoint]
astart = arec.annotations["start"] + len(aseq) - aseq.count("-")
logger.info("%s|%s", aseq[-FLANK:], arec.seq[midpoint:][:FLANK])
bseq = brec.seq[:midpoint]
bstart = brec.annotations["start"] + len(bseq) - bseq.count("-")
logger.info("%s|%s", bseq[-FLANK:], brec.seq[midpoint:][:FLANK])
bpt = Breakpoint(arec.id, astart, brec.id, bstart)
logger.info("-" * FLANK * 2 + ">")
logger.info("%s|%s", ar.seq[:astart][-FLANK:], br.seq[bstart:][:FLANK])
final.append(bpt)

logger.info("Breakpoints found: %s", final)
# Load the sequences
ar = next(SeqIO.parse(a_fasta, "fasta"))
br = next(SeqIO.parse(b_fasta, "fasta"))
if len(final) == 2:
bp1, bp2 = final[:2]
# ====-------=======
Expand Down

0 comments on commit 318d364

Please sign in to comment.