Skip to content

Performance optimization for mobile og pl#25

Open
DrKaiyangZheng wants to merge 5 commits into
clb21565:mainfrom
DrKaiyangZheng:Performance-optimization-for-mobileOG-pl
Open

Performance optimization for mobile og pl#25
DrKaiyangZheng wants to merge 5 commits into
clb21565:mainfrom
DrKaiyangZheng:Performance-optimization-for-mobileOG-pl

Conversation

@DrKaiyangZheng

Copy link
Copy Markdown

Enhanced CLI & Core Performance Optimization

Changes

1. CLI Enhancements (mobileOGs-pl-kyanite.sh & mobileOGs-pl-amethyst.sh)

Feature Description
-h, --help Added usage help. Previously -h caused silent exit.
-o, --out Redirect all outputs (.faa, .tsv, .csv) to a custom directory. Auto-creates directory.
--faa Accept pre-computed protein FASTA (e.g. from prodigal). Skips gene prediction step when provided.
Input validation -i/--input is now mandatory; script exits with error message if missing.

2. Core Performance Optimization (mobileOGs-pl-kyanite.py)

Bottleneck Fix Impact
Row-wise apply(lambda r: '_'.join(...)) str.rsplit('_', n=1).str[0] Eliminates Python-level loop; ~10–100× speedup on large datasets
7× redundant str.split('|') on same column Single split(..., expand=True) + multi-column assignment Reduces string scanning overhead
ORF counting via copy → drop_duplicates → groupby transform → drop_duplicates Direct groupby(...).nunique() Fewer DataFrame copies and passes
Nested for loops doing replace() Flat dictionary + vectorized replace() Entirely removes Python iteration over categories
Redundant merge(left_on=Series) syntax Clean left_on="column" Avoids spurious key_0 columns

3. Documentation (UsageGuidance.md)

  • Added "April 2026 Update" section documenting all new options.
  • Included usage examples for standard run, custom output directory, and --faa.

Backward Compatibility

  • Default behavior is preserved. Omitting -o writes to the current directory; omitting --faa runs prodigal as before.
  • Output values are numerically equivalent for standard prodigal-formatted input. The only intentional CSV-level changes are:
    • Added index=False to to_csv() calls (removes unwanted index column).
    • Percentage columns return 0.0 instead of NaN when Total Number of Hits = 0.

Testing

# Help
./mobileOGs-pl-kyanite.sh -h

# Standard run
./mobileOGs-pl-kyanite.sh -i test.fasta -d db.dmnd -m meta.csv -k 15 -e 1e-20 -p 90 -q 90

# Custom output + skip prodigal
./mobileOGs-pl-kyanite.sh -i test.fasta --faa test.faa -o ./results -d db.dmnd -m meta.csv -k 15 -e 1e-20 -p 90 -q 90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant