### Project Setup and Testing Tools
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Installs the project in editable mode and sets up testing dependencies including pytest, black, and mypy for code quality checks.
```bash
pip3 install -e .
pip3 install pytest black mypy
pytest
black pyhlamsa
mypy pyhlamsa
```
--------------------------------
### Install and Serve Documentation
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Installs necessary packages for documentation generation and serves the documentation locally. Requires Python 3.
```bash
pip3 install mkdocs-material mkdocstrings[python-lagacy]==0.18
mkdocs serve
```
--------------------------------
### Install pyHLAMSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Installs the pyHLAMSA library using pip. You can install directly from GitHub or by cloning the repository and installing locally.
```bash
pip3 install git+https://github.com/linnil1/pyHLAMSA
# or
git clone https://github.com/linnil1/pyHLAMSA
pip3 install -e pyHLAMSA
```
--------------------------------
### Install pyHLAMSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Install the pyHLAMSA package from GitHub using pip.
```bash
pip3 install git+https://github.com/linnil1/pyHLAMSA
```
--------------------------------
### Example Usage of CYP Variant Formatting
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Demonstrates how to format variation bases for a specific CYP gene (CYP26A1) using the cyp object. This is useful for visualizing sequence differences across different alleles.
```python
print(cyp['CYP26A1'].format_varition_base())
```
--------------------------------
### Get Consensus Sequence
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Determines the consensus sequence from an MSA. The `include_gap` parameter controls whether gaps are considered in determining the consensus. This is useful for identifying the most common nucleotide at each position.
```python
>>> exon23.get_consensus(include_gap=True)
'GCTCCC-ACTCCATGAGGTATTTCTTCACATCCGTGTCCCGGCCCGGCCGCGGGGA----GCCCCGCTTCATCGCCGTGGGC-----------------------TACGTGGACG-ACACG-CAGTTCGTGCGGTTCGACAGCGACGCCGCGAGCCAGAGGATGGAGCCG--------------------CGGGCGCCGTGGATA-GAGCAGGAGGGGCCGGAGTATTGGGACCAGGAGACACGGA-------------A-TGTGAAGGCCCACTCACAGACTGACCGAGTGGACCTGGGGACCCTGCGCGGCTACTACAACCAGAGCGAGGCCGGTTCTCACACC-ATCCAGATGATGTATGGCTGCGACG--------------TGGGG-TCGGACGGGCGCTTCCTCCGCGGGTACCAGCA---GGACGCCTACGACGGCAAGGATTAC---ATCGCCCTGAAC------------------------GAGGACCTGCGCTCTTGGACCGCGGCGGAC--------ATGGCGGCTCAGATCACCAAGCGC-AAGT----GGGAGG--CGGCCC-ATGT------------------------------------------GGCGG-AGCAGTTGAGAGCCTACCTGGAGGGCACG--------TGCGTG----GAGTGGCTCCG--CAGATA-CCTGGAGAACGGGAAGGAGACGCTGCAGC-----------------GCACGG'
```
--------------------------------
### Show pyHLAMSA help
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Display the help message for the pyHLAMSA command-line tool to see available commands and options.
```bash
pyhlamsa -h
```
--------------------------------
### Initialize CYPmsa
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Initializes the CYPmsa object by providing the path to the unzipped PharmVar folder. This is used for working with CYP gene alignments.
```python
# 4. Read it
from pyhlamsa import CYPmsa
cyp = CYPmsa(pharmvar_folder="./pharmvar-5.1.10")
```
--------------------------------
### Select and Print First 10 Alleles
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Selects the first 10 alleles from a dataset and prints the resulting alignment. Useful for a quick overview of initial alleles.
```python
# select first 10 alleles
>> exon23_10 = exon23.select_allele(exon23.get_sequence_names()[:10])
>>> print(exon23_10)
```
```python
# print it
>>> exon23_10.print_alignment()
812 1136
|
A*01:01:01:01 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:02N ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:03 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:04 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:05 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:06 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:07 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:08 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:09 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
A*01:01:01:10 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC-ATCCAGA TAATGTATGG CTGCGACG-- ----------
```
--------------------------------
### Add and Fill Sequences in MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Demonstrates how to add a consensus sequence to an existing MSA and then fill any incomplete sequences. This is useful for ensuring data completeness and consistency within the alignment.
```python
# Add sequence into MSA
# include_gap=False in get_consensus will ignore the frequency of gap. i.e. choose one of ATCG
>>> a_merged = hla["A"]
>>> consensus_seq = a_merged.get_consensus(include_gap=False)
>>> a_merged.append("A*consensus", consensus_seq)
>>> a_merged.fill_imcomplete("A*consensus")
```
--------------------------------
### Initialize KIRmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Initialize a KIRmsa object for a specified IPD folder and version, loading all KIR genes. If no specific genes are provided, it defaults to loading all available genes.
```python
from pyhlamsa import KIRmsa
# If don't specific the genes, it will read all genes.
kir = KIRmsa(ipd_folder="KIR_v2100", version="2100")
```
--------------------------------
### Initialize KIRmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Initialize a KIRmsa object to read KIR sequences from a specified folder and version. If no genes are specified, all available genes are read.
```python
from pyhlamsa import KIRmsa
# If don't specific the genes, it will read all genes.
kir = KIRmsa(ipd_folder="KIR_v2100", version="2100")
print(kir.list_genes())
print(kir["KIR2DL1"])
```
--------------------------------
### Initialize HLAmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Initialize an HLAmsa object for specified genes and version, loading data as genomic sequences. This is the first step to working with HLA data.
```python
from pyhlamsa import HLAmsa
hla = HLAmsa(["A", "B"], filetype="gen",
version="3470")
```
--------------------------------
### Select Alleles Using Regex and Print Differences
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Selects alleles matching a specific regex pattern and prints the alignment differences. This is useful for identifying variations within a specific subset of alleles.
```python
# using regex to select
# "|" indicate the border of block, in this case, it's the border of exon2 and exon3
>>> exon23_1field = exon23.select_allele(r"A\*.*:01:01:01$")
>>> exon23_1field.print_alignment_diff()
812 1136
|
A*01:01:01:01 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC.ATCCAGA TAATGTATGG CTGCGACG.. ..........
A*02:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.G------ GG-------- --------.. ..........
A*03:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.G------ GG-------- --------.. ..........
A*11:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
A*23:01:01:01 ------A--- ----C---T- GC--T-C--- ---------- --------C- -| --------- --.C------ -G----T--- --------.. ..........
A*25:01:01:01 ------A--G ----C---T- GC--T-C--- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*26:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*29:01:01:01 ---------- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- ----C---.. ..........
A*30:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- ---------- --------.. ..........
A*32:01:01:01 ------A--G ----C---T- GC--T-C--- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*33:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*34:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*36:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
A*66:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*68:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*69:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.G------ GG-------- --------.. ..........
A*74:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*80:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
```
--------------------------------
### Select Alleles Using Regex and Print Differences
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Selects alleles matching a specific regex pattern and prints the alignment differences. Useful for identifying variations based on naming conventions.
```python
# using regex to select
# "|" indicate the border of block, in this case, it's the border of exon2 and exon3
>>> exon23_1field = exon23.select_allele(r"A\*.*:01:01:01$")
>>> exon23_1field.print_alignment_diff()
812 1136
|
A*01:01:01:01 ACCGAGCGAA CCTGGGGACC CTGCGCGGCT ACTACAACCA GAGCGAGGAC G| GTTCTCACA CC.ATCCAGA TAATGTATGG CTGCGACG.. ..........
A*02:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.G------ GG-------- --------.. ..........
A*03:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- ---------- --------.. ..........
A*11:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
A*23:01:01:01 ------A--- ----C---T- GC--T-C--- ---------- --------C- -| --------- --.C------ -G----T--- --------.. ..........
A*25:01:01:01 ------A--G ----C---T- GC--T-C--- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*26:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*29:01:01:01 ---------- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- ----C---.. ..........
A*30:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- ---------- --------.. ..........
A*32:01:01:01 ------A--G ----C---T- GC--T-C--- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*33:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*34:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*36:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
A*66:01:01:01 ------T-G- ---------- ---------- ---------- ---------- -| --------- --.------- GG-------- --------.. ..........
A*68:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*69:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.G------ GG-------- --------.. ..........
A*74:01:01:01 ------T-G- ---------- ---------- ---------- --------C- -| --------- --.------- -G-------- --------.. ..........
A*80:01:01:01 ---------- ---------- ---------- ---------- ---------- -| --------- --.------- ---------- --------.. ..........
```
--------------------------------
### Download KIR sequences
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Download KIR gene sequences for a specific version and include selected genes. The downloaded data is saved to specified folders.
```bash
pyhlamsa download --family kir --db-folder tmpdir/tmp_kir_db --version 2100 tmpdir/kir --include-genes KIR2DL1 KIR2DL2
```
--------------------------------
### List genes in HLAmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
List all genes currently loaded in the HLAmsa object. This helps in verifying which genes are available for analysis.
```python
print(hla.list_genes())
```
--------------------------------
### List genes in KIRmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
List all genes available in the KIRmsa object. This provides an overview of the KIR genes that have been loaded.
```python
print(kir.list_genes())
```
--------------------------------
### Initialize HLAmsa object
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Initialize an HLAmsa object to read HLA sequences for specified genes and version. The object can then be used to list genes or access specific gene data.
```python
from pyhlamsa import HLAmsa
hla = HLAmsa(["A", "B"], filetype="gen",
version="3470")
print(hla.list_genes())
print(hla["A"])
```
--------------------------------
### Save MSA in FASTA Format
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Saves the alignment to a FASTA file. Use `gap=True` to preserve gaps in the alignment, and `gap=False` to save sequences without gaps.
```python
# Save as MSA
SeqIO.write(a_gen.to_records(gap=True), "filename.msa.fa", "fasta")
# Save as no-gapped sequences
SeqIO.write(a_gen.to_records(gap=False), "filename.fa", "fasta")
```
--------------------------------
### Shrink Alignment to Remove Gap Columns
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Use the `shrink()` method to remove columns where all bases are gaps. This is useful for cleaning up alignments.
```python
>>> exon23_10.shrink().print_snv()
gDNA 200
|
A*01:01:01:01 AAGGCCCACT CACAGACTGA CCGAGCGAAC CTGGGGACCC TGCGCGGCTA CTACAACCAG AGCGAGGACG| GTTCTCACAC CATCCAGATA ATGTATGGCT
A*01:01:01:02N ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:03 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:04 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:05 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:06 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:07 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:08 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:09 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
A*01:01:01:10 ---------- ---------- ---------- ---------- ---------- ---------- ----------| ---------- ---------- ----------
```
--------------------------------
### Select specific blocks (exons/introns) from an alignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Select specific blocks, including introns and exons, from an alignment object using 0-based indexing. This allows for precise selection of genomic regions.
```python
# select exon2 + intron2 + exon3
>>> e2i2e3 = a_gen.select_block([3,4,5]) # 0-base
>>> print(e2i2e3)
```
--------------------------------
### Load MSA from MultipleSeqAlignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Loads an MSA from a Biopython MultipleSeqAlignment object. This is useful for reading MSAs in various formats supported by Biopython's AlignIO.
```python
from pyhlamsa import Genemsa
msa = Genemsa.from_MultipleSeqAlignment(AlignIO.read(your_data_path, your_data_format))
```
--------------------------------
### Export MSA to FASTA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Exports the alignment to a FASTA file. The `gap` parameter controls whether gaps are included in the output.
```python
a_gen.to_fasta("filename.msa.fa", gap=True)
a_gen.to_fasta("filename.fa", gap=False)
```
--------------------------------
### Select Specific Columns from Alignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Slice an alignment object to select a range of columns. The result is an alignment object with fewer columns.
```python
>>> a_gen[12:100]
```
--------------------------------
### Print CYP Variant Base
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
This snippet demonstrates how to print the base variation of a specific CYP gene (CYP26A1) using the format_variantion_base() method. It shows different alleles and their base sequences.
```python
>>> print(cyp['CYP26A1'].format_variantion_base())
```
--------------------------------
### Export MSA to VCF
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Exports the alignment to a VCF (Variant Call Format) file, compressed with gzip. VCF is used for representing genetic variations.
```python
a_gen.to_vcf("filename.vcf.gz")
```
--------------------------------
### Save and Load MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Saves the MSA model to FASTA and JSON files. The JSON file stores block and index information. The `load_msa` function can then be used to reload the model.
```python
a_gen.save_msa("a_gen.fa", "a_gen.json")
a_gen = Genemsa.load_msa("a_gen.fa", "a_gen.json")
```
--------------------------------
### Save specific intron/exon regions to files
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Extract and save specific intron/exon regions from an MSA to various file formats including BAM, GFF, and gapless FASTA. This is useful for detailed analysis of specific genomic segments.
```bash
pyhlamsa view tmpdir/kir.KIR2DL1 --region intron1 exon1 --name tmpdir/kir1 --save --bam --gff --fasta-gapless --fasta-msa
```
--------------------------------
### Load merged genomic and nucleotide MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Load both genomic and nucleotide Multiple Sequence Alignment (MSA) data for a specified HLA gene and alignment folder. This allows for simultaneous analysis of genomic and exon-only sequences.
```python
# merge gen and nuc sequences when loading
>>> hla = HLAmsa(["A"], filetype=["gen", "nuc"],
imgt_alignment_folder="alignment_v3470")
>>> print(hla["A"])
```
--------------------------------
### Print Alignment Differences for Selected Columns
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Use `print_alignment_diff()` to display differences between sequences in specific columns. This is useful for visualizing variations.
```python
>>> a_gen[[12,100]].print_alignment_diff()
gDNA 0
|
A*01:01:01:01 GG
A*01:01:01:02N -G
A*01:01:01:03 GG
A*01:01:01:04 --
A*01:01:01:05 --
A*01:01:01:06 --
A*01:01:01:07 --
A*01:01:01:08 --
A*01:01:01:09 --
A*01:01:01:10 --
A*01:01:01:11 GG
A*01:01:01:12 GG
```
--------------------------------
### Load nucleotide MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Load nucleotide (exon-only) sequence data for a specific HLA gene from a given alignment folder. This is useful for analyzing coding regions.
```python
>>> a_nuc = HLAmsa("A", filetype="nuc",
>>> imgt_alignment_folder="alignment_v3470")["A"]
```
--------------------------------
### Export MSA to IMGT Alignment Format
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Exports the alignment in the IMGT (ImMunoGeneTics) alignment format. Specify `seq_type='nuc'` for nucleotide sequences.
```python
a_gen.to_imgt_alignment("A_gen.txt")
a_gen.to_imgt_alignment("A_nuc.txt", seq_type="nuc")
```
--------------------------------
### View specific region of an MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
View a portion of an MSA for a given gene, specifying positions and including specific alleles. This command is useful for inspecting alignment details.
```bash
pyhlamsa view tmpdir/kir.KIR2DL1 --position 3-100 --include-alleles KIR2DL1*consensus KIR2DL1*063
```
--------------------------------
### Export MSA to BAM
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Exports the alignment to a BAM file. This format is commonly used in genomics for storing sequence alignment data.
```python
a_gen.to_bam("filename.bam")
```
--------------------------------
### Load genomic MSA
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Load genomic sequence data for a specific HLA gene from a given alignment folder. This is used for detailed analysis of the full gene sequence.
```python
# or manually
>>> a_gen = HLAmsa("A", filetype="gen",
>>> imgt_alignment_folder="alignment_v3470")["A"]
```
--------------------------------
### Merge genomic and nucleotide sequences
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Load and merge genomic (gen) and nucleotide (nuc) sequences for a gene. Introns in the genomic sequence are filled with 'E' after merging with the exon-only nucleotide sequence.
```python
# merge gen and nuc sequences when loading
>>> hla = HLAmsa(["A"], filetype=["gen", "nuc"],
imgt_alignment_folder="alignment_v3470")
>>> print(hla["A"])
# or manually
>>> a_gen = HLAmsa("A", filetype="gen",
>>> imgt_alignment_folder="alignment_v3470")["A"]
>>> print(a_gen)
>>> a_nuc = HLAmsa("A", filetype="nuc",
>>> imgt_alignment_folder="alignment_v3470")["A"]
>>> print(a_nuc)
>>> a_gen = a_gen.remove('A*03:437Q')
>>> print(a_gen.merge_exon(a_nuc))
```
--------------------------------
### Export MSA to GFF
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Exports the alignment to a GFF (General Feature Format) file. This format is used for describing gene and protein features.
```python
a_gen.to_gff("filename.gff")
```
--------------------------------
### Convert to MultipleSeqAlignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Converts a gene alignment object to a Biopython MultipleSeqAlignment object. This is useful for further processing with Biopython tools.
```python
>>> print(a_gen.to_MultipleSeqAlignment())
Alignment with 4100 rows and 3866 columns
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...AAA A*01:01:01:01
--------------------------------------------...--- A*01:01:01:02N
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...AAA A*01:01:01:03
--------------------------------------------...--- A*01:01:01:04
--------------------------------------------...AAA A*01:01:01:05
--------------------------------------------...--- A*01:01:01:06
--------------------------------------------...AAA A*01:01:01:07
--------------------------------------------...--- A*01:01:01:08
--------------------------------------------...AAA A*01:01:01:09
--------------------------------------------...--- A*01:01:01:10
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...--- A*01:01:01:11
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...AAA A*01:01:01:12
--------------------------------------------...AAA A*01:01:01:13
--------------------------------------------...AAA A*01:01:01:14
--------------------------------------------...--- A*01:01:01:15
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...--- A*01:01:01:16
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...--- A*01:01:01:17
CAGGAGCAGAGGGGTCAGGGCGAAGTCCCAGGGCCCCAGGCGTG...AAA A*01:01:01:18
...
--------------------------------------------...--- A*80:07
```
--------------------------------
### Concatenate Exons from Alignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Use `select_exon()` to extract specific exons and then concatenate them using the `+` operator. This creates a new alignment object with combined exons.
```python
>>> print(a_gen.select_exon([2]) + a_gen.select_exon([3]))
```
--------------------------------
### Access KIR gene data
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Access the data for a specific KIR gene (e.g., 'KIR2DL1') from the KIRmsa object. This provides detailed information about the gene's alleles and structural blocks.
```python
print(kir["KIR2DL1"])
```
--------------------------------
### Select specific exons from an alignment
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Select specific exons from an HLA alignment object. Exons are 1-based indexed. This returns a new alignment object containing only the selected exons.
```python
# select exon2 and exon3
>>> exon23 = a_gen.select_exon([2,3]) # 1-base
>>> print(exon23)
```
--------------------------------
### Print Sequence Variation
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Displays the total variation count and a detailed alignment of sequence variations for a given exon. This is useful for visualizing differences between HLA alleles.
```python
>>> exon23_1field.print_snv()
Total variantion: 71
536 537 541 565 567 570 593 640 654 658 684 721
| | | | | | | | | | | |
A*01:01:01:01 | ATTTCT TCAC ATCCG| CCGGC CG CGG GGA.G | ATCGCCGTGG | .G.ACACG.C | CGTGCGGTTC GACA| AGA..A GATG| CGGGCG CCGT|
A*02:01:01:01 | ------ ---- -----| ----- -- --- ---.- | -----A---- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*03:01:01:01 | ------ ---- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*11:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*23:01:01:01 | ------ C--- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*25:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*26:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*29:01:01:01 | -----A C--- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------T ----| ---..G ----| -----A ----|
A*30:01:01:01 | ------ C--- -----| ----- A- T-- A--.- | -----A---- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*32:01:01:01 | ------ ---- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------T ----| ---..G ----| ------ ----|
A*33:01:01:01 | -----A C--- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*34:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*36:01:01:01 | ------ ---- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..- ----| ------ ----|
A*66:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*68:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*69:01:01:01 | ------ A--- C----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------- ----| ---..G ----| ------ ----|
A*74:01:01:01 | ------ ---- -----| ----- -- --- ---.- | ---------- | .-.-----.- | ---------T ----| ---..G ----| ------ ----|
A*80:01:01:01 | ------ ---- -----| ----- -- --- ---.- | -----A---- | .-.--T--.- | -----A---- ----| ---..G ----| ------ ----|
```
--------------------------------
### Merge genomic and nucleotide sequences
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Merge nucleotide (exon-only) sequence data into a genomic sequence object. Introns in the genomic sequence are filled with 'E' after merging.
```python
>>> a_gen = a_gen.remove('A*03:437Q')
>>> print(a_gen.merge_exon(a_nuc))
```
--------------------------------
### Access HLA gene data
Source: https://github.com/linnil1/pyhlamsa/blob/main/README.md
Access the data for a specific HLA gene (e.g., 'A') from the HLAmsa object. This returns an object containing detailed information about the gene's alleles and structure.
```python
print(hla["A"])
```
--------------------------------
### Calculate Sequence Variation Frequency
Source: https://github.com/linnil1/pyhlamsa/blob/main/docs/README.md
Calculates the frequency of each base (A, T, C, G, -) for every position in a Multiple Sequence Alignment (MSA). This helps in understanding the distribution of nucleotides across aligned sequences.
```python
>>> print(exon23.calculate_frequency()[:10])
[[2, 3, 0, 4095, 0], [2, 1, 4097, 0, 0], [0, 4098, 2, 0, 0], [0, 3, 4095, 2, 0], [0, 911, 3188, 0, 1], [0, 1, 4097, 1, 1], [0, 0, 1, 0, 4099], [4097, 0, 0, 2, 1], [4, 3, 4090, 3, 0], [1, 4097, 1, 1, 0]]
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.