freqsap.__main__

Command-line interface for the freqsap package.

This module provides the main entry point for querying protein variants and their population frequencies from various databases.

Functions

parse_args(→ argparse.Namespace)

Parse command line arguments.

write_reports(→ None)

Write all reports to the output file in delimited format.

_write_csv(→ None)

Write reports to a delimited text file (CSV/TSV).

_write_xlsx(→ None)

Write reports to an Excel file (XLSX format).

check_apis(→ None)

Check if the chosen APIs are available.

main(→ None)

Main entry point for the freqsap application.

Module Contents

freqsap.__main__.parse_args() argparse.Namespace[source]

Parse command line arguments.

Returns:

Parsed command line arguments containing:
  • accession: Protein accession identifier

  • output: Path to output file

  • protein_api: Protein variant API choice (uniprot or ebi)

  • frequency_api: Variant frequency API choice (dbsnp)

  • delimiter: Output file delimiter (default: tab)

Return type:

argparse.Namespace

freqsap.__main__.write_reports(reports: list[freqsap.report.ReferenceSNPReport], regions: list[str], output_path: str, delimiter: str) None[source]

Write all reports to the output file in delimited format.

Parameters:
  • reports – List of ReferenceSNPReport objects to write

  • regions – List of region populations to report.

  • output_path – Path to the output file

  • delimiter – Character to use as field delimiter (e.g., ‘t’ or ‘,’). Use ‘xlsx’ for Excel format.

Returns:

None

Raises:
  • IOError – If the output file cannot be written

  • IndexError – If reports list is empty

freqsap.__main__._write_csv(reports: list[freqsap.report.ReferenceSNPReport], regions: list[str], output_path: str, header: list[str], delimiter: str) None[source]

Write reports to a delimited text file (CSV/TSV).

Parameters:
  • reports – List of ReferenceSNPReport objects to write

  • regions – List of populations to report.

  • output_path – Path to the output file

  • header – List of column headers

  • delimiter – Character to use as field delimiter

Returns:

None

freqsap.__main__._write_xlsx(reports: list[freqsap.report.ReferenceSNPReport], regions: list[str], output_path: str, header: list[str]) None[source]

Write reports to an Excel file (XLSX format).

Parameters:
  • reports – List of ReferenceSNPReport objects to write

  • regions – List of region populations to report.

  • output_path – Path to the output file

  • header – List of column headers

Returns:

None

Raises:

ImportError – If openpyxl is not installed

freqsap.__main__.check_apis(protein_api: freqsap.interfaces.ProteinVariantAPI, frequency_api: freqsap.interfaces.VariantFrequencyAPI) None[source]

Check if the chosen APIs are available.

Parameters:
  • protein_api – Instance of the protein variant API

  • frequency_api – Instance of the variant frequency API

Returns:

None

Raises:

SystemExit – If either API is not available

freqsap.__main__.main() None[source]

Main entry point for the freqsap application.

This function orchestrates the entire workflow: 1. Parses command line arguments 2. Instantiates the chosen protein and frequency APIs 3. Validates API availability 4. Queries protein variants using the accession 5. Collects frequency reports for all variants 6. Writes results to the specified output file

Returns:

None

Raises:

SystemExit – If APIs are unavailable or other errors occur