protein_blast()
Find the best hit of each gene in the query cluster's proteins.
Every protein is aligned globally with every protein of the query cluster (Needleman-Wunsch, as R's protein_blast() with pwalign::pairwiseAlignment(); see aligner for the scores). A gene keeps the query protein with the highest identity as its hit, when the identity is at least identity; equal best hits give a row each. The clusters are then ordered by a synteny score, the query first.
Needs Biopython: pip install "geneviewer-py[align]".
Usage
from geneviewer import protein_blast
protein_blast(
data,
query,
id='protein_id',
start='start',
end='end',
cluster='cluster',
genes=None,
identity=30,
)Arguments
| Argument | Type | Description |
|---|---|---|
data | pandas.DataFrame or path | Genes with their protein sequence (column translation or sequence), or a GenBank file or folder of them (one cluster per file). |
query | str | The query cluster. |
id | str | Column of unique protein ids. |
start, end | str | Columns of the start and end positions. |
cluster | str | Column of cluster names. |
genes | list of str, optional | Only these genes of the query cluster (by id). Default: all. |
identity | float | The lowest identity (percent) of a hit. Default 30. |
Value
pandas.DataFrame: data (rows without an id, sequence or cluster left out) with rowID, start, end, and identity, similarity, BlastP (the id of the hit, "No Hit" without one; a hit only one gene has is "No Hit" too) and score (the cluster's synteny score). Ordered by cluster, the query first, then by score.
Errors
| Error | When |
|---|---|
ImportError | Without Biopython. |
ValueError | When a column or the query is not in the data. |
Examples
>>> genes = pd.DataFrame({
... "protein_id": ["A1", "A2", "B1", "B2"],
... "cluster": ["A", "A", "B", "B"],
... "start": [1, 200, 1, 200], "end": [150, 350, 150, 350],
... "translation": ["MKTAYIAKQRQISFVKSHFSRQ", "MSDNELLKRLGEAVLAHPTTG",
... "MKTAYIAKQRQISFVKSHFSRQ", "MLPGGRTSWVQEHCDKAYNIF"]})
>>> protein_blast(genes, query="A")[["protein_id", "identity", "BlastP"]]
protein_id identity BlastP
0 A1 100.0 A1
1 A2 100.0 No Hit
2 B1 100.0 A1
3 B2 NaN No Hit