Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sbslee committed Mar 31, 2023
1 parent 79f4c55 commit 61fbca8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion fuc/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,12 @@ def parse_variant(variant):

def extract_sequence(fasta, region):
"""
Extract the region's DNA sequence from the FASTA file.
Extract the DNA sequence corresponding to a selected region from a FASTA
file.
The method also allows users to retrieve the reference allele of a
variant in a genomic coordinate format, instead of providing a genomic
region.
Parameters
----------
Expand All @@ -817,6 +822,17 @@ def extract_sequence(fasta, region):
-------
str
DNA sequence. Empty string if there is no matching sequence.
Examples
--------
>>> from fuc import common
>>> fasta_file = 'resources_broad_hg38_v0_Homo_sapiens_assembly38.fasta'
>>> common.extract_sequence(fasta_file, 'chr1:15000-15005')
'GATCCG'
>>> # rs1423852 is chr16-80874864-C-T
>>> common.extract_sequence(fasta_file, 'chr16:80874864-80874864')
'C'
"""
try:
sequence = pysam.faidx(fasta, region).split('\n')[1]
Expand Down

0 comments on commit 61fbca8

Please sign in to comment.