Skip to content

Commit

Permalink
Merge pull request #29 from maxibor/fix_index_error
Browse files Browse the repository at this point in the history
Fix IndexError
  • Loading branch information
maxibor authored Jan 23, 2025
2 parents 65f40b4 + 4d5fc95 commit ff29afa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
python-version: "3.10"
- name: Build pydamage
run: |
pip install wheel
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/pydamage_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip_ci]')"
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v3
- uses: mamba-org/setup-micromamba@v2
with:
auto-update-conda: true
mamba-version: "*"
channels: conda-forge,bioconda,defaults
channel-priority: true
environment-file: environment.yml
activate-environment: pydamage
environment-name: pydamage
init-shell: >-
bash
cache-environment: true
post-cleanup: 'all'
- name: Test with pytest
shell: bash -l {0}
shell: bash -el {0}
run: |
pip install -e .
pip install pytest
pytest
- name: Check pydamage help message
shell: bash -l {0}
shell: bash -el {0}
run: |
pydamage --help
- name: Check pydamage on test data
shell: bash -l {0}
shell: bash -el {0}
run: |
pydamage analyze --verbose tests/data/aligned.bam
pydamage filter pydamage_results/pydamage_results.csv
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: pydamage
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- click
- numpy
Expand Down
2 changes: 1 addition & 1 deletion pydamage/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.80"
__version__ = "0.90"
from pydamage.main import pydamage_analyze
import logging

Expand Down
18 changes: 14 additions & 4 deletions pydamage/damage.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@ def compute_damage(self):
# All conserved C and G
no_mut_pos, no_mut_counts = sort_count_array_dict(np.array(self.no_mut, dtype="uint32"))


CT_damage_amount = np.zeros(self.wlen)
CT_damage_amount[CT_pos] = CT_counts / C_counts[CT_pos]
C_pos_dict = {pos: i for i, pos in enumerate(C_pos)}
CT_pos_indices = [C_pos_dict[pos] for pos in CT_pos]
CT_damage_amount[CT_pos] = CT_counts / C_counts[CT_pos_indices]

GA_damage_amount = np.zeros(self.wlen)
GA_damage_amount[GA_pos] = GA_counts / G_counts[GA_pos]
G_pos_dict = {pos: i for i, pos in enumerate(G_pos)}
GA_pos_indices = [G_pos_dict[pos] for pos in GA_pos]

GA_damage_amount[GA_pos] = GA_counts / G_counts[GA_pos_indices]


damage_amount = np.zeros(self.wlen)
damage_amount[damage_bases_pos] = damage_bases_counts / C_G_bases_counts[damage_bases_pos]
CG_pos_dict = {pos: i for i, pos in enumerate(C_G_bases_pos)}
CG_pos_indices = [CG_pos_dict[pos] for pos in damage_bases_pos]
damage_amount[damage_bases_pos] = damage_bases_counts / C_G_bases_counts[CG_pos_indices]


_ = np.zeros(self.wlen, dtype="uint32")
_[damage_bases_pos] = damage_bases_counts
Expand Down Expand Up @@ -251,4 +261,4 @@ def test_damage(ref, bam, mode, wlen, g2a, subsample, show_al, process, verbose)
f" - reflen: {reflen}\n"
)
al_handle.close()
return False
return False, read_dict
2 changes: 2 additions & 0 deletions pydamage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def pydamage_analyze(
# bam=bam,
# ref=ref,
# wlen=wlen,
# g2a=g2a,
# subsample=subsample,
# show_al=show_al,
# mode=mode,
# process=process,
Expand Down

0 comments on commit ff29afa

Please sign in to comment.