Skip to main content

CoDing Sequence Typer (CDST): MD5 hash-based genome typing and clustering

Project description

CDST

CoDing Sequence Typer (CDST) is a simple, efficient, decentralized, and easily shareable genome typing and clustering method similar to cg/wgMLST, based on MD5 hash mapping of coding sequences (CDS) from genome assemblies.


DEPENDENCIES

Before running CDST, ensure that the following dependencies are installed:

Python Packages:

  • argparse
  • hashlib
  • json
  • pandas
  • biopython
  • networkx
  • scipy

Install them using:

pip install biopython pandas networkx scipy

Tested Environment

We tested the pipeline in the following environment:

  • Python 3.12
  • Biopython 1.85
  • pandas 2.2.2
  • SciPy 1.13.1
  • scikit-learn 1.5.1
  • networkx 3.3
  • matplotlib 3.9.x
  • joblib 1.4.x

Other versions may also work, but have not been systematically tested.

INSTALLATION

Clone this repository and navigate into the project folder:

git clone https://github.com/l1-mh/cdst.git
cd cdst

Make the script executable:

chmod +x cdst.py

Alternatively, you can run it directly using Python:

python cdst.py --help

USAGE

CDST provides multiple subcommands for different analysis steps.

Run the Full Pipeline Above:

cdst.py run -i sample_cds/*.ffn -o output/ -T both

Generate the Distance Matrix, MST, and Hierarchical Clusters from CDS Sequences:

  1. Generate JSON database of MD5 Hashes from CDS FASTA Files:
cdst.py generate -i sample_cds/*.ffn -o output/
  1. Compute Distance Matrices:
cdst.py matrix -j output/md5_hashes.json -o output/
  1. Generate Minimum Spanning Tree (MST):
cdst.py mst -m output/difference_matrix.csv -o output/
  1. (Optional) Generate Hierarchical Clustering Tree:
cdst.py hc -m output/difference_matrix.csv -o output/

Merge Databases:

Can do with only JSON databases. But merging JSON databases with Distance Matrixes (with --matrix flag) will save you time.

Use --mst flag if you want to produce the MST.

Make sure that every corresponding Distance Matrix file are in the same folder with JSON database and the file names are as below:

  • /dir1/md5_hashes.json
  • /dir1/comparison_matrix.csv
python cdst.py join -d dir1/ dir2/ -o merged_output/ --matrix --mst

Compare New Samples Against an Existing Dataset:

python cdst.py test -i new_samples/*.ffn -j output/md5_hashes.json -o output/

INPUT FILES

CDST requires FASTA-formatted CDS sequences as input. Each sequence should be in standard FASTA format (also known as .FFN format), such as:

>gene1
ATGCGTACGTAGCTAGCTAG
>gene2
ATGCGTAGCTAGCTAGTACG

Predicting CDS from Genome Assemblies

If you have a genome assembly (FASTA format), you need to predict CDS sequences before using CDST. We recommend Prodigal, a widely used gene prediction tool for prokaryotic genomes.

Run the following command to predict CDS from an assembly file:

prodigal -i assembly.fasta -d cds_output.ffn

The resulting cds_output.ffn file can be directly used as input for CDST.

  • You may use other CDS prediction tools like Glimmer or Augustus, but ensure consistency across samples.

  • If your dataset already contains FASTA-formatted CDS, no additional processing is needed.

  • CDS sequences containing ambiguous characters (e.g., N) will be ignored by CDST.

OUTPUT FILES

Depending on the commands used, the following files will be generated:

  • md5_hashes.json: Stores MD5 hashes for CDS sequences.
  • comparison_matrix.csv: Number of shared hashes between samples.
  • difference_matrix.csv: Distance matrix based on hash differences.
  • edge_list.csv: Edge list representation of pairwise distances.
  • mst.csv: Minimum Spanning Tree (MST) edge list.
  • hc.newick: Hierarchical Clustering tree in Newick format.
  • comparison_results.csv: Closest matches (for new samples comparisons only).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdst_genome-0.2.0.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdst_genome-0.2.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file cdst_genome-0.2.0.tar.gz.

File metadata

  • Download URL: cdst_genome-0.2.0.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for cdst_genome-0.2.0.tar.gz
Algorithm Hash digest
SHA256 496374d1cc8ca717048d3a24833a6b8b501d5cf942120e0a1ab0a4b85b8cf3ab
MD5 ea9151d8dba496f274467745e4d4ab70
BLAKE2b-256 d7bec2192f70c2f3b96bac1b4ebf98b0deae6e3d76a4263947668507d9c6ccf2

See more details on using hashes here.

File details

Details for the file cdst_genome-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cdst_genome-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for cdst_genome-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b757ee21b2843d93e86931731e1810b16ceadef6942c54b69ecde9eda0243b9
MD5 7f3c872aa71a1922e2b7e400b70a7959
BLAKE2b-256 565d96e03389f3775bb1c466ac97cc38a64cab6b082f48e82bf78f85f62341bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page