friend1ws / nanomonsv

SV detection tool for nanopore sequence reads
GNU General Public License v3.0
78 stars 12 forks source link

Bug Report: Input not found with symlinked input BAMs #28

Closed zhemingfan closed 1 year ago

zhemingfan commented 1 year ago

System Info

System Information Version
OS Ubuntu 18.04.2 LTS
python 3.8.3
singularity 3.5.2-1.1.el7
nanomonsv nanomonsv_0.5.0--pyhdfd78af_0.sif

Bug:

Currently nanomonsv checks if there is a file associated with the BAM path: https://github.com/friend1ws/nanomonsv/blob/40cda8c61f3711cf55d2a9b39c7c3ab31ee4e1ba/nanomonsv/utils.py#L18.

After running singularity exec nanomonsv_0.5.0--pyhdfd78af_0.sif nanomonsv parse symlinked_file.bam COLO829

I was thrown the error message: 12/16/2022 11:55:31 - nanomonsv.utils - ERROR - Input not exists: symlinked_file.bam

Expected Behaviour:

We expect that a symlinked file is able to return None and proceed with the process.

Additional Testing:

Strangely, with further tests, this was able to return None, but not in the containerized version of NanomonSV.

import os
import sys
import logging 

def get_logger(mod_name):

    logger = logging.getLogger(mod_name)
    logger.propagate = False

    if not logger.hasHandlers(): 
        ch = logging.StreamHandler()
        formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S')
        ch.setFormatter(formatter)
        logger.addHandler(ch)

    logger.setLevel(logging.INFO)

    return logger

logger = get_logger(__name__)

def is_exists(input_file):
    if not os.path.exists(input_file):
        logger.error("Input not exists: %s" % input_file)
        sys.exit(1)

def is_exists_bam(input_file):

    if input_file.startswith("s3://"):
        is_exists_s3(input_file)
    else:
        is_exists(input_file)

print(os.path.exists('symlinkedfile.bam')) #Returns True
print(os.path.isfile('symlinkedfile.bam')) #Returns True
print(is_exists_bam('symlinkedfile.bam')) #Returns None
print(is_exists_bam('nonsymlinkedpath.py')) #Returns None
print(is_exists_bam('fakefilepath.py')) #Throws sys.arg with logger error 
zhemingfan commented 1 year ago

Resolved internally.