Skip to content

Commit

Permalink
separate out simple helper function to check file exists for use acro…
Browse files Browse the repository at this point in the history
…ss other files
  • Loading branch information
ashuaibi7 committed Nov 19, 2024
1 parent 56152c3 commit e535562
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/dialect/utils/generate.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import os
import logging
import subprocess
import numpy as np
import pandas as pd

import logging
from dialect.utils.helpers import *

# ---------------------------------------------------------------------------- #
# Helper Functions #
# ---------------------------------------------------------------------------- #


def check_file_exists(maf):
"""
Checks if the specified file exists.
@param maf: Path to the file to validate.
Raises FileNotFoundError if the file does not exist.
"""
logging.info(f"Validating input file: {maf}")
if not os.path.exists(maf):
raise FileNotFoundError(f"File not found: {maf}")


def convert_maf_to_CBaSE_input_file(maf, out):
"""
Converts a MAF file to the CBaSE accepted VCF input format with sample barcode in the last column.
Expand Down
14 changes: 14 additions & 0 deletions src/dialect/utils/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import logging


def check_file_exists(fn):
"""
Checks if the specified file exists.
@param fn: Path to the file to validate.
Raises FileNotFoundError if the file does not exist.
"""
logging.info(f"Validating input file: {fn}")
if not os.path.exists(fn):
raise FileNotFoundError(f"File not found: {fn}")

0 comments on commit e535562

Please sign in to comment.