Parsomics Documentation

website·Indexed 29 days ago

https://parsomics.org

Documentation for Parsomics, a platform for processing protein annotation and prokaryote genome data. Includes guides on using the parsomics-cli, database management via SQL and REST API, and a comprehensive developer guide for creating and publishing plugins to support various formats like GTDB-Tk, dRep, Prokka, and InterProScan.

Tokens
17.4K
Snippets
87
Records
131
Agent score
49%

What's inside Parsomics

  1. Overview of Parsomics data processing and storage

    Parsomics is a tool that processes data and inserts it into a standardized PostgreSQL relational database schema. By using a relational database, it allows users to perform complex data retrieval using SQL queries. The system abstracts processed data using database entities that represent biological concepts.
  2. Overview of the parsomics project

    The parsomics project provides a suite of data management tools specifically for metagenomics research. Its primary function is data integration: it processes output files from various metagenomics tools and converts them into a standardized relational database representation.
  3. Overview of the parsomics project architecture

    The parsomics project consists of a set of core modules and specialized plugin modules. The core functionality is provided by parsomics-core, parsomics-api-server, and parsomics-cli. Extendability is achieved through plugin modules, which include parsomics-plugin-clean, parsomics-plugin-dbcan, parsomics-plugin-interpro, and parsomics-plugin-proteinfer.
  4. Understand dbCAN3 data normalization in Parsomics

    Parsomics normalizes the non-normalized overview.txt format from run_dbCAN. It transforms multiple annotation columns (HMMER, dbCAN_sub, DIAMOND) into individual rows. Additionally, it extracts start and stop coordinates from descriptions (e.g., "CE4(38-162)") into separate coord_start and coord_stop fields.
  5. Understand the Parsomics database schema structure

    The Parsomics relational database schema defines the logical organization of data. It consists of tables (relations), columns (attributes) with specific data types, primary and foreign keys, and constraints such as NOT NULL and UNIQUE. This schema acts as the blueprint for how data is stored and related within the system.
  6. Define the drepentry database entity

    The drepentry table stores information about genomes and their clusters as assigned by dRep, including whether a genome is the representative 'winner' for its cluster. It maintains a relationship with the drepdirectory table.
    CREATE TABLE drepentry (
        genome_name VARCHAR NOT NULL,
        genome_cluster_name VARCHAR NOT NULL,
        is_winner BOOLEAN NOT NULL,
        directory_key INTEGER NOT NULL,
        key SERIAL NOT NULL,
        PRIMARY KEY (key),
        UNIQUE (genome_name, directory_key),
        FOREIGN KEY(directory_key) REFERENCES drepdirectory (key)
    )
  7. Understand parsomics project architecture and modules

    The parsomics project is organized into multiple repositories called 'modules'. Key modules include:

    • parsomics-core: Library for inserting data into the database.
    • parsomics-api-server: A REST API for database interaction.
    • parsomics-cli: Command-line interface for managing analyzes, databases, and plugins.
    • parsomics-plugin-interpro: A plugin for processing InterproScan annotations.
  8. Understand the parsomics data pipeline hierarchy

    Data ingestion in parsomics follows a hierarchical structure:

    • Parsing: The procedure of adding data and metadata from a single file into the relational database.
    • Processing: The procedure of adding data from all files of a specific tool run. One processing consists of multiple parsings.
    • Analysis: The complete procedure of processing files from all runs specified in the configuration file. One analysis consists of multiple processings.
  9. Format dbCAN3 overview.txt files for import

    The overview.txt files must be TSV files including a header row. The columns must appear in the exact order listed below. The Gene ID column must contain the protein name used to identify the protein in the Parsomics database.
    Column nameObligatorinessData typeNullability
    Gene IDMandatoryStringNot nullable
    EC#OptionalStringNullable
    HMMEROptionalStringNullable
    dbCAN_subOptionalStringNullable
    DIAMONDOptionalStringNullable
    eCAMIOptionalStringNullable
    SignalpOptional (ignored)StringN/A
    #ofToolsOptional (ignored)IntegerN/A
  10. Create a ValidatedFileWithGenome subclass for a plugin

    To define which files your plugin should process and how to extract the genome name, create a subclass of ValidatedFileWithGenome.

    1. Define _VALID_FILE_TERMINATIONS: A ClassVar[list[str]] containing the file extensions or suffixes that identify valid files. These must be specific enough to distinguish actual data files from logs or other noise in the output directory.
    2. Implement the genome_name property: This method should return the genome name as a string, typically by removing the defined terminations from the filename.
    from pathlib import Path
    from typing import ClassVar
    from parsomics_core.entities.files.validated_file import ValidatedFileWithGenome
    
    class InterproTsvValidatedFile(ValidatedFileWithGenome):
        # Define suffixes that identify valid files
        _VALID_FILE_TERMINATIONS: ClassVar[list[str]] = [
            "_interpro_out.tsv",
            "_interpro.tsv",
        ]
    
        @property
        def genome_name(self) -> str:
            file_name: str = Path(self.path).name
    
            # Remove valid file terminations to extract genome name
            for termination in InterproTsvValidatedFile._VALID_FILE_TERMINATIONS:
                file_name = file_name.removesuffix(termination)
    
            genome_name = file_name
            if genome_name is None:
                raise Exception(
                    f"Failed at extracting genome name from interpro tsv file: {self.path}"
                )
    
            return genome_name
  11. Use parsomics-core plugin utilities

    To avoid duplicate work and standardize the codebase, developers should use the utility functions provided by the parsomics-core library. These utilities are available in the parsomics_core.plugin_utils module. For example, search_protein_by_name can be used to find proteins by their names.
    from parsomics_core.plugin_utils import search_protein_by_name
  12. Query the parsomics database using SQL

    The parsomics database can be queried using any SQL client. The parsomics team recommends using DBeaver for improved readability of results via tables and the ability to save queries for later use.