INNER CODE UNIT · Python

read_and_preprocess

BortonWrightonLabs/DRAM · bin/combine_annotations.py:16

def read_and_preprocess(
    path: Path, input_fasta: str, seperator=","
) -> pl.LazyFrame | None:
    # We design input fastas from intermediate steps to be named like:
    # "input_fasta___some_information_annotation_file.tsv"
    # input_fasta = input_fasta_from_filepath(path)
    try:
        lf = pl.scan_csv(path, separator=seperator).with_columns(
            pl.lit(input_fasta).alias(FASTA_COLUMN)
        )
        # Validate here so we can log file-specific parse failures before the final collect.
        lf.collect_schema()
        return lf
    except Exception as e:
        logger.error(f"Error loading DataFrame for input_fasta {input_fasta}: {str(e)}")
        return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…