Skip to content

Commit

Permalink
fast fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-eyes committed Oct 27, 2024
1 parent c85a478 commit 6eea33c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/snipe/cli/cli_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def process_subset(
except Exception as e:
subset_logger.error(f"Failed to load variance signature from {path}: {e}")
return {}, subset # All samples in this subset fail

# Initialize QC instance
try:
qc_inst = MultiSigReferenceQC(
Expand All @@ -200,20 +200,16 @@ def process_subset(
except Exception as e:
subset_logger.error(f"Failed to initialize MultiSigReferenceQC: {e}")
return {}, subset # All samples in this subset fail

predict_extra_folds = [1, 2, 5, 9]

subset_stats = {}
subset_failed = []
for sample_path in subset:
sample_sig = SnipeSig(sourmash_sig=sample_path, sig_type=SigType.SAMPLE, enable_logging=debug)
if sample_sig.name == "":
_newname = os.path.basename(sample_path).split('.')[0]
sample_sig.name = _newname
print(sample_sig)
if len(sample_sig.hashes) == 0:
e_msg = f"Sample signature is empty. This might be coming from sketching reads with length < {sample_sig.ksize}, or super small sample."
raise ValueError(e_msg)
subset_logger.warning(f"Sample name is empty. Setting to: `{sample_sig.name}`")

try:
Expand Down Expand Up @@ -830,6 +826,9 @@ def qc(ref: str, sample: List[str], samples_from_file: Optional[str],

# make sure all integer columns are converted to int
df = df.apply(lambda col: col.apply(lambda x: int(x) if isinstance(x, float) and x.is_integer() else x))
df_zero_uniqe_hashes = df[df["Total unique k-mers"] == 0]
df = df[df["Total unique k-mers"] != 0]
logger.warning(f"Empty sigs not processed: {len(df_zero_uniqe_hashes)}: {', '.join(df_zero_uniqe_hashes['filename'])}")

try:
with open(output, 'w', encoding='utf-8') as f:
Expand Down

0 comments on commit 6eea33c

Please sign in to comment.