epi2me-labs / pore-c-py

Other
12 stars 4 forks source link

Pore-c-py annotate giving error #6

Closed luantune closed 5 months ago

luantune commented 9 months ago

Hello, I am currently trying to run pore-c-py annotate and being running into some errors that I cannot figure it out.

The code i am running is: pore-c-py annotate --monomers --chromunity --paired_end /pore-c_new_pipeline/AllHiCN117_digested_aligned_unaligned_ns.bam /pore-c_results/AllHiCN11_annotated

where my input bam comes from an unaligned bam result from pore-c-py digest and an aligned bam resulting from my unaligned bam being converted to a fastq with samtools and then mapped with minimap2 and then converted back into a bam file with samtools. I then went ahead and merged both of my aligned and unaligned bam files and then namesorted the merged bam file. The error I keep getting is:

pore-c-py annotate --monomers --chromunity --paired_end /pore-c_new_pipeline/AllHiCN117_digested_aligned_ns.bam AllHiCN11_annotated [14:03:43 - AnntateBAM] Processing reads from /pore-c_new_pipeline/AllHiCN117_digested_aligned_ns.bam Traceback (most recent call last): File "/lustre03/project/6058390/luantune/pore-c-py_ENV/bin/pore-c-py", line 8, in sys.exit(run_main()) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 408, in run_main args.func(args) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 287, in annotate_bam outputs += namesorted_bam TypeError: 'PosixPath' object is not iterable

I am running this inside beluga cluster of compute canada.

thanks in advance.

luantune commented 9 months ago

I managed to debug and move forward but now I have this issue: Traceback (most recent call last): File "/lustre03/project/6058390/luantune/pore-c-py_ENV/bin/pore-c-py", line 8, in sys.exit(run_main()) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 408, in run_main args.func(args) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 316, in annotate_bam for concat_walk in annotate.annotate_alignments(inbam): File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/annotate.py", line 67, in annotate_alignments for concat_id, aligns in groupby( File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/annotate.py", line 69, in lambda x: x.get_tag(utils.CONCATEMER_ID_TAG)): File "pysam/libcalignedsegment.pyx", line 2503, in pysam.libcalignedsegment.AlignedSegment.get_tag File "pysam/libcalignedsegment.pyx", line 2542, in pysam.libcalignedsegment.AlignedSegment.get_tag KeyError: "tag 'MI' not present"

cjw85 commented 9 months ago

Hi @luantune,

We do not have a full tutorial as the project was created for use within our wf-pore-c workflow.

I think your latest error results from you merging your aligned and unaligned BAMs and having not preserved the BAM tags during alignment with minimap2.

We would recommend using the workflow listed above, but the correct way to use pore-c-py directly would be something like:

pore-c-py digest concatemers.bam "NlaIII" \
    | samtools fastq -T '*' \
    | minimap2 -ay -t 64 -x map-ont "reference.fasta.mmi" - \
    | pore-c-py annotate - "all" --monomers --threads 1 --stdout true --summary \
    | tee "all.ns.bam" \
    | samtools sort --write-index -o "all.cs.bam" -

This will give you two aligned BAM files, one name sorted and the second co-ordinated sorted.

luantune commented 9 months ago

Hello, I still get the same error: File "/lustre03/project/6058390/luantune/pore-c-py_ENV/bin/pore-c-py", line 8, in sys.exit(run_main()) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 408, in run_main args.func(args) File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/main.py", line 316, in annotate_bam for concat_walk in annotate.annotate_alignments(inbam): File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/annotate.py", line 67, in annotate_alignments for concat_id, aligns in groupby( File "/lustre03/project/6058390/luantune/pore-c-py_ENV/lib/python3.8/site-packages/pore_c_py/annotate.py", line 69, in lambda x: x.get_tag(utils.CONCATEMER_ID_TAG)): File "pysam/libcalignedsegment.pyx", line 2503, in pysam.libcalignedsegment.AlignedSegment.get_tag File "pysam/libcalignedsegment.pyx", line 2542, in pysam.libcalignedsegment.AlignedSegment.get_tag KeyError: "tag 'MI' not present"

I do get some files but I see that in the summary file there is nothing inside, just the header so I am scared to move forward with my bam files as I do not know if the job ran.

ahcm commented 9 months ago

Seems like --header needs an argument:

usage: pore-c-py digest [-h] [--debug | --quiet] [--logfile LOGFILE]
                        [--output OUTPUT] [--header HEADER] [--recursive]
                        [--glob GLOB]
                        [--remove_tags REMOVE_TAGS [REMOVE_TAGS ...]]
                        [--max_monomers MAX_MONOMERS]
                        [--excluded_list EXCLUDED_LIST]
                        [--excluded_bam EXCLUDED_BAM] [--threads THREADS]
                        [input ...] enzyme
pore-c-py digest: error: argument --header: expected one argument
cjw85 commented 9 months ago

I have updated the comment above to remove the unnecessary --header argument.