From d26c030fe67ddc6c25377b52d6abfb2ae1d4634c Mon Sep 17 00:00:00 2001 From: tombch Date: Wed, 11 Oct 2023 12:19:59 +0100 Subject: [PATCH] Updated README with python script example --- README.md | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4aad681..d97d23a 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,12 @@ ``` $ pip install maptide ``` -Depending on your operating system, the Rust compiler may need to be installed. - -Installation instructions for the Rust compiler can be found here: https://www.rust-lang.org/tools/install #### Build from source Building from source requires the Rust compiler. +Installation instructions for the Rust compiler can be found here: https://www.rust-lang.org/tools/install + Once the Rust compiler is installed: ``` $ git clone https://github.com/CLIMB-COVID/maptide.git @@ -46,12 +45,12 @@ options: Number of decimal places to display (default: 3) ``` -#### Frequencies over all positions: +#### Frequencies over all positions ``` $ maptide /path/to/file.bam ``` -#### Frequencies over a region: +#### Frequencies over a region ``` $ maptide /path/to/file.bam --region chrom:start-end ``` @@ -63,3 +62,25 @@ Index files that do not follow the naming convention `/path/to/file.bam.bai` can ``` $ maptide /path/to/file.bam --region chrom:start-end --index /path/to/index.bai ``` + +#### Example in Python +`maptide` can be used within Python scripts: + +```python +import maptide + +data = maptide.query( + "path/to/file.bam", + region="MN908947.3:100-200", # Obtain frequencies only in this region + annotated=True, # Annotate frequencies with their bases A,C,G,T,DS,N +) + +chrom = "MN908947.3" # Chosen reference/chromosome in the BAM to access +position = (100, 0) # Position 100, insert 0 (i.e. not an insertion) + +# With annotated = True, frequencies are annotated with their bases: +frequencies = data[chrom][position] +print(frequencies) # {'A': 1, 'C': 122, 'G': 0, 'T': 1, 'DS': 13, 'N': 0} + +# If annotated = False, frequencies would be a list i.e. [1, 122, 0, 1, 13, 0] +``` \ No newline at end of file