Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inumanag committed Nov 1, 2024
1 parent 44a7ab9 commit 9d103e1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion aldy/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def update(self, kwargs):
else:
try:
if isinstance(self.__dict__[n], bool):
self.__dict__[n] = not (v in ['False', '0'])
self.__dict__[n] = not (v in ["False", "0"])
else:
typ = type(self.__dict__[n])
self.__dict__[n] = typ(v)
Expand Down
52 changes: 38 additions & 14 deletions aldy/sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,26 +355,50 @@ def parse(start, ref, alt):
with open(path) as f:
self._prefix = "" # no chr prefix assumed
self.name = os.path.splitext(os.path.basename(path))[0]
for l in f:
if l.startswith("#") or l.startswith("probeset_id\t"): continue
l = l.strip().split('\t')
_, genotype, _, chrom, start, stop, _, rsid, _, _, _, _, _, _, _, _, _, ref, alt, *_ = l
for line in f:
if line.startswith("#") or line.startswith("probeset_id\t"):
continue
line = line.strip().split("\t")
(
_,
genotype,
_,
chrom,
start,
stop,
_,
rsid,
_,
_,
_,
_,
_,
_,
_,
_,
_,
ref,
alt,
*_,
) = line
start, stop = int(start) - 1, int(stop)
if chrom != self.gene.chr:
continue
if start not in self.gene:
continue
genotype = genotype.split('/')
genotype = genotype.split("/")
if len(genotype) != 2:
continue
if ref != '-':
if ref != "-":
if self.gene[start:stop] != ref and self.gene[start:stop] == alt:
ref, alt = alt, ref
if self.gene[start:stop] != ref:
log.debug(f"Issue: REF {ref} (ALT {alt}) "
f"does not match {self.gene[start:stop]}")
log.debug(
f"Issue: REF {ref} (ALT {alt}) "
f"does not match {self.gene[start:stop]}"
)
ref = self.gene[start:stop] # only for PScan/TPMT
alt = alt.split('//')
alt = alt.split("//")
if len(alt) > 1:
for g in genotype:
if g in alt:
Expand All @@ -385,11 +409,11 @@ def parse(start, ref, alt):
start, ref, alt = parse(start, ref, alt)

r, m = 20, 0
mc = f'{ref}>{alt}'
if alt == '-':
mc = f'del{ref}'
if ref == '-':
mc = f'ins{alt}'
mc = f"{ref}>{alt}"
if alt == "-":
mc = f"del{ref}"
if ref == "-":
mc = f"ins{alt}"
mut = (start, mc)
for g in genotype:
if g in alt:
Expand Down

0 comments on commit 9d103e1

Please sign in to comment.