Protein
Protein objects and functions.
NoExtractor
Bases: ProteinNameExtractor
Protein name extractor that performs no operations.
Used when no extraction needed.
Source code in src/xlranker/bio/protein.py
__init__()
extract(isoform_name)
Returns the input isoform_name without any modifications.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isoform_name
|
str
|
name of the isoform |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
same string as input |
Protein
Protein class that has the name and abundance for the protein.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the protein |
required |
protein_name
|
str
|
name of the protein specific to the isoform level. |
required |
abundances
|
dict[str, float | None]
|
Abundance values of the protein where keys is the name of the data and the value is the abundance |
{}
|
main_column
|
str | None
|
column/key in abundance dictionary that represents the main abundance for the protein. Used for sorting the proteins. If none, uses first key in abundances dict. |
None
|
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the protein |
abundances |
dict[str, float | None]
|
Abundance values of the protein where keys is the name of the data and the value is the abundance |
main_column |
str
|
column/key in abundance dictionary that represents the main abundance for the protein. Used for sorting the proteins. |
protein_name |
str
|
name of the protein specific to the isoform level. |
Source code in src/xlranker/bio/protein.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
__eq__(value)
Determine if object is equal to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
object
|
object to compare to |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
If input is not a Protein object, returns False. Returns true if protein_name is the same for both proteins. |
Source code in src/xlranker/bio/protein.py
__hash__()
Get hash representation of this object.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
hash using the protein name of this protein |
__init__(name, protein_name, abundances={}, main_column=None)
Protein class that has the name and abundance for the protein.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the protein |
required |
protein_name
|
str
|
name of the protein specific to the isoform level. |
required |
abundances
|
dict[str, float | None]
|
Abundance values of the protein where keys is the name of the data and the value is the abundance |
{}
|
main_column
|
str | None
|
column/key in abundance dictionary that represents the main abundance for the protein. Used for sorting the proteins. If none, uses first key in abundances dict. |
None
|
Source code in src/xlranker/bio/protein.py
abundance()
Get the representative abundance value for this protein.
Uses the main_column attribute to get a value from the abundances dictionary.
Returns:
Type | Description |
---|---|
float | None
|
float | None: Abundance value if available. If main_column is invalid, returns None. |
Source code in src/xlranker/bio/protein.py
ProteinNameExtractor
Bases: ABC
Abstract class describing methods for a protein name extractor from isoform name.
Source code in src/xlranker/bio/protein.py
__init__()
abstractmethod
extract(isoform_name)
abstractmethod
Method to extract protein from isoform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isoform_name
|
str
|
name of the isoform that needs extraction |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
string of the protein name without any isoform information |
Source code in src/xlranker/bio/protein.py
SplitExtractor
Bases: ProteinNameExtractor
Protein name extractor that extracts a section from a isoform name using a splitting char and index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
split_by
|
str
|
string or char to split the isoform name by |
required |
split_index
|
int
|
index to extract the protein name from after splitting the isoform name |
required |
Attributes:
Name | Type | Description |
---|---|---|
split_by |
str
|
string or char to split the isoform name by |
split_index |
int
|
index to extract the protein name from after splitting the isoform name |
Source code in src/xlranker/bio/protein.py
__init__(split_by, split_index)
Initialize the split extractor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
split_by
|
str
|
string or char to split the isoform name by |
required |
split_index
|
int
|
index to extract the protein name from after splitting the isoform name |
required |
Source code in src/xlranker/bio/protein.py
extract(isoform_name)
Extract a section from isoform name using split_by and split_index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isoform_name
|
str
|
isoform name needing extraction |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
string of the protein name |
Source code in src/xlranker/bio/protein.py
sort_proteins(a, b)
Takes into two Proteins and returns them so the first protein is higher abundant. Handles missing values.
In the case of missing values for both proteins or equal values, the input order is maintained.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a
|
Protein
|
first protein |
required |
b
|
Protein
|
second protein |
required |
Returns:
Type | Description |
---|---|
tuple[Protein, Protein]
|
tuple[Protein, Protein]: protein tuple where the first protein is the higher abundant protein |