Skip to content

Commit b2b38bb

Browse files
authored
Merge pull request #52 from Juke34/he
Adding hyper editing processing
2 parents 76923cd + 05a7a32 commit b2b38bb

File tree

29 files changed

+447
-39
lines changed

29 files changed

+447
-39
lines changed

bin/restore_sequences.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Restore original sequences in BAM files from original unmapped BAM.
4+
This tool replaces modified sequences with their original counterparts.
5+
"""
6+
7+
import sys
8+
import argparse
9+
import pysam
10+
11+
12+
def fix_bam(bam_aligned, bam_unmapped, bam_out):
13+
"""Restore original sequences using indexed lookup."""
14+
# Create index for fast read name lookup
15+
unmapped = pysam.AlignmentFile(bam_unmapped, "rb")
16+
unmapped_index = pysam.IndexedReads(unmapped)
17+
unmapped_index.build()
18+
19+
with pysam.AlignmentFile(bam_aligned, "rb") as bamfile:
20+
with pysam.Samfile(bam_out, 'wb', template=bamfile) as out:
21+
for read in bamfile:
22+
try:
23+
# Fetch original read by name (returns iterator)
24+
for orig_read in unmapped_index.find(read.query_name):
25+
read.query_sequence = orig_read.query_sequence
26+
read.query_qualities = orig_read.query_qualities
27+
read.set_tag("MD", None)
28+
break # Take first match
29+
out.write(read)
30+
except KeyError:
31+
pass # Read not found in unmapped BAM
32+
33+
unmapped.close()
34+
35+
36+
def main():
37+
parser = argparse.ArgumentParser(description=__doc__)
38+
parser.add_argument("-b", "--bam", required=True, help="aligned BAM file")
39+
parser.add_argument("-u", "--unmapped", required=True, help="original unmapped BAM file")
40+
parser.add_argument("-o", "--output", required=True, help="output BAM file")
41+
args = parser.parse_args()
42+
43+
fix_bam(args.bam, args.unmapped, args.output)
44+
45+
46+
if __name__ == "__main__":
47+
sys.exit(main())

build_containers.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ if [ "$build_docker" = true ]; then
115115
# List of image names
116116
image_list=( )
117117

118-
for dir in docker/*; do
118+
for dir in containers/docker/*; do
119119
cd "${dir}"
120120
imgname=$(echo $dir | rev | cut -d/ -f1 | rev)
121121
image_list+=(${imgname})
@@ -161,7 +161,7 @@ if [ "$build_singularity" = true ]; then
161161
sif_list=( )
162162

163163
# Loop through all .def files in singularity/ subdirectories
164-
for def_file in singularity/*/*.def; do
164+
for def_file in containers/singularity/*/*.def; do
165165
# Extract image name from directory
166166
imgname=$(basename "$(dirname "$def_file")")
167167
sif_output="sif_images/${imgname}.sif"

config/softwares.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ process {
4646
container = 'quay.io/biocontainers/star:2.7.10b--h6b7c446_1'
4747
}
4848
withLabel: 'samtools' {
49-
container = 'quay.io/biocontainers/samtools:1.3.1--h0cf4675_11'
49+
container = 'quay.io/biocontainers/samtools:1.23--h96c455f_0'
5050
}
5151
withLabel: "sapin" {
5252
container = singularity.enabled ? "${params.sifPath}/sapin.sif" : "sapin"

docker/pluviometer/env_pluviometer.yml renamed to containers/docker/pluviometer/env_pluviometer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dependencies:
5151
- typing_extensions=4.13.2=pyh29332c3_0
5252
- tzdata=2025b=h78e105d_0
5353
- wheel=0.45.1=pyhd8ed1ab_1
54+
- pysam=0.23.3=py312h47d5410_1
5455
- pip:
5556
- flameprof==0.4
5657
prefix: /home/earx/miniforge3/envs/rain-stats-scripts
File renamed without changes.

0 commit comments

Comments
 (0)