SciCodePile commited on
Commit
b64c69a
·
verified ·
1 Parent(s): 455af53

Upload data/dataset_Hydrophilic.csv with huggingface_hub

Browse files
Files changed (1) hide show
  1. data/dataset_Hydrophilic.csv +2177 -0
data/dataset_Hydrophilic.csv ADDED
@@ -0,0 +1,2177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "keyword","repo_name","file_path","file_extension","file_size","line_count","content","language"
2
+ "Hydrophilic","openvax/pepdata","setup.py",".py","2574","77","# Copyright (c) 2014-2018. Mount Sinai School of Medicine
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ from __future__ import print_function, division, absolute_import
18
+ import os
19
+ import re
20
+
21
+ from setuptools import setup, find_packages
22
+
23
+ readme_dir = os.path.dirname(__file__)
24
+ readme_path = os.path.join(readme_dir, 'README.md')
25
+
26
+ try:
27
+ with open(readme_path, 'r') as f:
28
+ readme_markdown = f.read()
29
+ except:
30
+ print(""Failed to load README file"")
31
+ readme_markdown = """"
32
+
33
+ try:
34
+ import pypandoc
35
+ readme_restructured = pypandoc.convert(readme_markdown, to='rst', format='md')
36
+ except:
37
+ readme_restructured = readme_markdown
38
+ print(""Conversion of long_description from markdown to reStructuredText failed, skipping..."")
39
+
40
+ with open('pepdata/__init__.py', 'r') as f:
41
+ version = re.search(
42
+ r'^__version__\s*=\s*[\'""]([^\'""]*)[\'""]',
43
+ f.read(),
44
+ re.MULTILINE).group(1)
45
+
46
+ if __name__ == '__main__':
47
+ setup(
48
+ name='pepdata',
49
+ version=version,
50
+ description=""Immunological peptide datasets and amino acid properties"",
51
+ author=""Alex Rubinsteyn"",
52
+ author_email=""alex.rubinsteyn@mssm.edu"",
53
+ url=""https://github.com/openvax/pepdata"",
54
+ license=""http://www.apache.org/licenses/LICENSE-2.0.html"",
55
+ classifiers=[
56
+ 'Development Status :: 3 - Alpha',
57
+ 'Environment :: Console',
58
+ 'Operating System :: OS Independent',
59
+ 'Intended Audience :: Science/Research',
60
+ 'License :: OSI Approved :: Apache Software License',
61
+ 'Programming Language :: Python',
62
+ 'Topic :: Scientific/Engineering :: Bio-Informatics',
63
+ ],
64
+ install_requires=[
65
+ 'numpy>=1.7',
66
+ 'scipy>=0.9',
67
+ 'pandas>=0.17',
68
+ 'scikit-learn>=0.14.1',
69
+ 'progressbar33',
70
+ 'biopython>=1.65',
71
+ 'datacache>=0.4.4',
72
+ 'lxml',
73
+ ],
74
+ long_description=readme_restructured,
75
+ packages=find_packages(exclude=""test""),
76
+ include_package_data=True
77
+ )
78
+ ","Python"
79
+ "Hydrophilic","openvax/pepdata","deploy.sh",".sh","273","10","./lint.sh && \
80
+ ./test.sh && \
81
+ python3 -m pip install --upgrade build && \
82
+ python3 -m pip install --upgrade twine && \
83
+ rm -rf dist && \
84
+ python3 -m build && \
85
+ git --version && \
86
+ python3 -m twine upload dist/* && \
87
+ git tag ""$(python3 pepdata/version.py)"" && \
88
+ git push --tags","Shell"
89
+ "Hydrophilic","openvax/pepdata","develop.sh",".sh","25","4","set -e
90
+
91
+ pip install -e .
92
+ ","Shell"
93
+ "Hydrophilic","openvax/pepdata","lint.sh",".sh","154","10","#!/bin/bash
94
+ set -o errexit
95
+
96
+ find pepdata test -name '*.py' \
97
+ | xargs pylint \
98
+ --errors-only \
99
+ --disable=print-statement
100
+
101
+ echo 'Passes pylint check'
102
+ ","Shell"
103
+ "Hydrophilic","openvax/pepdata","test.sh",".sh","56","4","pytest --cov=pepdata/ --cov-report=term-missing tests
104
+
105
+
106
+ ","Shell"
107
+ "Hydrophilic","openvax/pepdata","pepdata/common.py",".py","967","28","# Copyright (c) 2014-2016. Mount Sinai School of Medicine
108
+ #
109
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
110
+ # you may not use this file except in compliance with the License.
111
+ # You may obtain a copy of the License at
112
+ #
113
+ # http://www.apache.org/licenses/LICENSE-2.0
114
+ #
115
+ # Unless required by applicable law or agreed to in writing, software
116
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
117
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118
+ # See the License for the specific language governing permissions and
119
+ # limitations under the License.
120
+
121
+
122
+ from __future__ import print_function, division, absolute_import
123
+
124
+ import numpy as np
125
+
126
+ def transform_peptide(peptide, property_dict):
127
+ return np.array([property_dict[amino_acid] for amino_acid in peptide])
128
+
129
+ def transform_peptides(peptides, property_dict):
130
+ return np.array([
131
+ [property_dict[aa] for aa in peptide]
132
+ for peptide in peptides])
133
+
134
+ ","Python"
135
+ "Hydrophilic","openvax/pepdata","pepdata/static_data.py",".py","741","19","# Licensed under the Apache License, Version 2.0 (the ""License"");
136
+ # you may not use this file except in compliance with the License.
137
+ # You may obtain a copy of the License at
138
+ #
139
+ # http://www.apache.org/licenses/LICENSE-2.0
140
+ #
141
+ # Unless required by applicable law or agreed to in writing, software
142
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
143
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144
+ # See the License for the specific language governing permissions and
145
+ # limitations under the License.
146
+
147
+
148
+ from __future__ import print_function, division, absolute_import
149
+ from os.path import dirname, realpath, join
150
+
151
+ PACKAGE_DIR = dirname(realpath(__file__))
152
+ MATRIX_DIR = join(PACKAGE_DIR, 'matrices')
153
+ ","Python"
154
+ "Hydrophilic","openvax/pepdata","pepdata/version.py",".py","121","8","__version__ = ""1.2.0""
155
+
156
+
157
+ def print_version():
158
+ print(f""v{__version__}"")
159
+
160
+ if __name__ == ""__main__"":
161
+ print_version()","Python"
162
+ "Hydrophilic","openvax/pepdata","pepdata/__init__.py",".py","597","27","from .amino_acid_alphabet import (
163
+ AminoAcid,
164
+ canonical_amino_acids,
165
+ canonical_amino_acid_letters,
166
+ extended_amino_acids,
167
+ extended_amino_acid_letters,
168
+ amino_acid_letter_indices,
169
+ amino_acid_name_indices,
170
+ )
171
+ from .peptide_vectorizer import PeptideVectorizer
172
+ from .version import __version__
173
+ from . import iedb
174
+
175
+
176
+
177
+ __all__ = [
178
+ ""iedb"",
179
+ ""AminoAcid"",
180
+ ""canonical_amino_acids"",
181
+ ""canonical_amino_acid_letters"",
182
+ ""extended_amino_acids"",
183
+ ""extended_amino_acid_letters"",
184
+ ""amino_acid_letter_indices"",
185
+ ""amino_acid_name_indices"",
186
+ ""PeptideVectorizer"",
187
+ ]
188
+ ","Python"
189
+ "Hydrophilic","openvax/pepdata","pepdata/amino_acid.py",".py","1287","37","# Licensed under the Apache License, Version 2.0 (the ""License"");
190
+ # you may not use this file except in compliance with the License.
191
+ # You may obtain a copy of the License at
192
+ #
193
+ # http://www.apache.org/licenses/LICENSE-2.0
194
+ #
195
+ # Unless required by applicable law or agreed to in writing, software
196
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
197
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
198
+ # See the License for the specific language governing permissions and
199
+ # limitations under the License.
200
+
201
+
202
+ from __future__ import print_function, division, absolute_import
203
+
204
+ class AminoAcid(object):
205
+ def __init__(
206
+ self, full_name, short_name, letter, contains=None):
207
+ self.letter = letter
208
+ self.full_name = full_name
209
+ self.short_name = short_name
210
+ if not contains:
211
+ contains = [letter]
212
+ self.contains = contains
213
+
214
+ def __str__(self):
215
+ return (
216
+ (""AminoAcid(full_name='%s', short_name='%s', letter='%s', ""
217
+ ""contains=%s)"") % (
218
+ self.letter, self.full_name, self.short_name, self.contains))
219
+
220
+ def __repr__(self):
221
+ return str(self)
222
+
223
+ def __eq__(self, other):
224
+ return other.__class__ is AminoAcid and self.letter == other.letter
225
+ ","Python"
226
+ "Hydrophilic","openvax/pepdata","pepdata/amino_acid_alphabet.py",".py","4682","161","# Licensed under the Apache License, Version 2.0 (the ""License"");
227
+ # you may not use this file except in compliance with the License.
228
+ # You may obtain a copy of the License at
229
+ #
230
+ # http://www.apache.org/licenses/LICENSE-2.0
231
+ #
232
+ # Unless required by applicable law or agreed to in writing, software
233
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
234
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
235
+ # See the License for the specific language governing permissions and
236
+ # limitations under the License.
237
+
238
+
239
+ """"""
240
+ Quantify amino acids by their physical/chemical properties
241
+ """"""
242
+
243
+ from __future__ import print_function, division, absolute_import
244
+
245
+ import numpy as np
246
+
247
+ from .amino_acid import AminoAcid
248
+
249
+ canonical_amino_acids = [
250
+ AminoAcid(""Alanine"", ""Ala"", ""A""),
251
+ AminoAcid(""Arginine"", ""Arg"", ""R""),
252
+ AminoAcid(""Asparagine"",""Asn"", ""N""),
253
+ AminoAcid(""Aspartic Acid"", ""Asp"", ""D""),
254
+ AminoAcid(""Cysteine"", ""Cys"", ""C""),
255
+ AminoAcid(""Glutamic Acid"", ""Glu"", ""E""),
256
+ AminoAcid(""Glutamine"", ""Gln"", ""Q""),
257
+ AminoAcid(""Glycine"", ""Gly"", ""G""),
258
+ AminoAcid(""Histidine"", ""His"", ""H""),
259
+ AminoAcid(""Isoleucine"", ""Ile"", ""I""),
260
+ AminoAcid(""Leucine"", ""Leu"", ""L""),
261
+ AminoAcid(""Lysine"", ""Lys"", ""K""),
262
+ AminoAcid(""Methionine"", ""Met"", ""M""),
263
+ AminoAcid(""Phenylalanine"", ""Phe"", ""F""),
264
+ AminoAcid(""Proline"", ""Pro"", ""P""),
265
+ AminoAcid(""Serine"", ""Ser"", ""S""),
266
+ AminoAcid(""Threonine"", ""Thr"", ""T""),
267
+ AminoAcid(""Tryptophan"", ""Trp"", ""W""),
268
+ AminoAcid(""Tyrosine"", ""Tyr"", ""Y""),
269
+ AminoAcid(""Valine"", ""Val"", ""V"")
270
+ ]
271
+
272
+ canonical_amino_acid_letters = [aa.letter for aa in canonical_amino_acids]
273
+
274
+ ###
275
+ # Post-translation modifications commonly detected by mass-spec
276
+ ###
277
+
278
+ # TODO: figure out three letter codes for modified AAs
279
+
280
+ modified_amino_acids = [
281
+ AminoAcid(""Phospho-Serine"", ""Sep"", ""s""),
282
+ AminoAcid(""Phospho-Threonine"", ""???"", ""t""),
283
+ AminoAcid(""Phospho-Tyrosine"", ""???"", ""y""),
284
+ AminoAcid(""Cystine"", ""???"", ""c""),
285
+ AminoAcid(""Methionine sulfoxide"", ""???"", ""m""),
286
+ AminoAcid(""Pyroglutamate"", ""???"", ""q""),
287
+ AminoAcid(""Pyroglutamic acid"", ""???"", ""n""),
288
+ ]
289
+
290
+ ###
291
+ # Amino acid tokens which represent multiple canonical amino acids
292
+ ###
293
+ wildcard_amino_acids = [
294
+ AminoAcid(""Unknown"", ""Xaa"", ""X"", contains=set(canonical_amino_acid_letters)),
295
+ AminoAcid(""Asparagine-or-Aspartic-Acid"", ""Asx"", ""B"", contains={""D"", ""N""}),
296
+ AminoAcid(""Glutamine-or-Glutamic-Acid"", ""Glx"", ""Z"", contains={""E"", ""Q""}),
297
+ AminoAcid(""Leucine-or-Isoleucine"", ""Xle"", ""J"", contains={""I"", ""L""})
298
+ ]
299
+
300
+ ###
301
+ # Canonical amino acids + wilcard tokens
302
+ ###
303
+
304
+ canonical_amino_acids_with_unknown = canonical_amino_acids + wildcard_amino_acids
305
+
306
+
307
+ ###
308
+ # Rare amino acids which aren't considered part of the core 20 ""canonical""
309
+ ###
310
+
311
+ rare_amino_acids = [
312
+ AminoAcid(""Selenocysteine"", ""Sec"", ""U""),
313
+ AminoAcid(""Pyrrolysine"", ""Pyl"", ""O""),
314
+ ]
315
+
316
+ ###
317
+ # Extended amino acids + wildcard tokens
318
+ ###
319
+
320
+ extended_amino_acids = canonical_amino_acids + rare_amino_acids + wildcard_amino_acids
321
+ extended_amino_acid_letters = [
322
+ aa.letter for aa in extended_amino_acids
323
+ ]
324
+ extended_amino_acids_with_unknown_names = [
325
+ aa.full_name for aa in extended_amino_acids
326
+ ]
327
+
328
+
329
+ amino_acid_letter_indices = {
330
+ c: i for (i, c) in
331
+ enumerate(extended_amino_acid_letters)
332
+ }
333
+
334
+
335
+ amino_acid_letter_pairs = [
336
+ ""%s%s"" % (x, y)
337
+ for y in extended_amino_acids
338
+ for x in extended_amino_acids
339
+ ]
340
+
341
+
342
+ amino_acid_name_indices = {
343
+ aa_name: i for (i, aa_name)
344
+ in enumerate(extended_amino_acids_with_unknown_names)
345
+ }
346
+
347
+ amino_acid_pair_positions = {
348
+ pair: i for (i, pair) in enumerate(amino_acid_letter_pairs)
349
+ }
350
+
351
+ def index_to_full_name(idx):
352
+ return extended_amino_acids[idx].full_name
353
+
354
+ def index_to_short_name(idx):
355
+ return extended_amino_acids[idx].short_name
356
+
357
+ def index_to_letter(idx):
358
+ return extended_amino_acids[idx]
359
+
360
+ def letter_to_index(x):
361
+ """"""
362
+ Convert from an amino acid's letter code to its position index
363
+ """"""
364
+ assert x in amino_acid_letter_indices, ""Unknown amino acid: %s"" % x
365
+ return amino_acid_letter_indices[x]
366
+
367
+ def peptide_to_indices(xs):
368
+ return [amino_acid_letter_indices[x] for x in xs]
369
+
370
+ def letter_to_short_name(x):
371
+ return index_to_short_name(letter_to_index(x))
372
+
373
+ def peptide_to_short_amino_acid_names(xs):
374
+ return [amino_acid_letter_indices[x] for x in xs]
375
+
376
+ def dict_to_amino_acid_matrix(d, alphabet=canonical_amino_acids):
377
+ n_aa = len(d)
378
+ result_matrix = np.zeros((n_aa, n_aa), dtype=""float32"")
379
+ for i, aa_row in enumerate(alphabet):
380
+ d_row = d[aa_row.letter]
381
+ for j, aa_col in enumerate(alphabet):
382
+ value = d_row[aa_col.letter]
383
+ result_matrix[i, j] = value
384
+ return result_matrix
385
+
386
+ ","Python"
387
+ "Hydrophilic","openvax/pepdata","pepdata/amino_acid_properties.py",".py","6268","360","# Licensed under the Apache License, Version 2.0 (the ""License"");
388
+ # you may not use this file except in compliance with the License.
389
+ # You may obtain a copy of the License at
390
+ #
391
+ # http://www.apache.org/licenses/LICENSE-2.0
392
+ #
393
+ # Unless required by applicable law or agreed to in writing, software
394
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
395
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
396
+ # See the License for the specific language governing permissions and
397
+ # limitations under the License.
398
+
399
+ from __future__ import print_function, division, absolute_import
400
+
401
+ from .amino_acid_alphabet import letter_to_index
402
+
403
+ """"""
404
+ Quantify amino acids by their physical/chemical properties
405
+ """"""
406
+
407
+
408
+ def aa_dict_to_positional_list(aa_property_dict):
409
+ value_list = [None] * 20
410
+ for letter, value in aa_property_dict.items():
411
+ idx = letter_to_index(letter)
412
+ assert idx >= 0
413
+ assert idx < 20
414
+ value_list[idx] = value
415
+ assert all(elt is not None for elt in value_list), \
416
+ ""Missing amino acids in:\n%s"" % aa_property_dict.keys()
417
+ return value_list
418
+
419
+ def parse_property_table(table_string):
420
+ value_dict = {}
421
+ for line in table_string.splitlines():
422
+ line = line.strip()
423
+ if not line:
424
+ continue
425
+ fields = line.split("" "")
426
+ fields = [f for f in fields if len(f.strip()) > 0]
427
+ assert len(fields) >= 2
428
+ value, letter = fields[:2]
429
+ assert letter not in value_dict, ""Repeated amino acid "" + line
430
+ value_dict[letter] = float(value)
431
+ return value_dict
432
+
433
+
434
+ """"""
435
+ Amino acids property tables copied from CRASP website
436
+ """"""
437
+
438
+ hydropathy = parse_property_table(""""""
439
+ 1.80000 A ALA
440
+ -4.5000 R ARG
441
+ -3.5000 N ASN
442
+ -3.5000 D ASP
443
+ 2.50000 C CYS
444
+ -3.5000 Q GLN
445
+ -3.5000 E GLU
446
+ -0.4000 G GLY
447
+ -3.2000 H HIS
448
+ 4.50000 I ILE
449
+ 3.80000 L LEU
450
+ -3.9000 K LYS
451
+ 1.90000 M MET
452
+ 2.80000 F PHE
453
+ -1.6000 P PRO
454
+ -0.8000 S SER
455
+ -0.7000 T THR
456
+ -0.9000 W TRP
457
+ -1.3000 Y TYR
458
+ 4.20000 V VAL
459
+ """""")
460
+
461
+ volume = parse_property_table(""""""
462
+ 91.5000 A ALA
463
+ 202.0000 R ARG
464
+ 135.2000 N ASN
465
+ 124.5000 D ASP
466
+ 118.0000 C CYS
467
+ 161.1000 Q GLN
468
+ 155.1000 E GLU
469
+ 66.40000 G GLY
470
+ 167.3000 H HIS
471
+ 168.8000 I ILE
472
+ 167.9000 L LEU
473
+ 171.3000 K LYS
474
+ 170.8000 M MET
475
+ 203.4000 F PHE
476
+ 129.3000 P PRO
477
+ 99.10000 S SER
478
+ 122.1000 T THR
479
+ 237.6000 W TRP
480
+ 203.6000 Y TYR
481
+ 141.7000 V VAL
482
+ """""")
483
+
484
+ polarity = parse_property_table(""""""
485
+ 0.0000 A ALA
486
+ 52.000 R ARG
487
+ 3.3800 N ASN
488
+ 40.700 D ASP
489
+ 1.4800 C CYS
490
+ 3.5300 Q GLN
491
+ 49.910 E GLU
492
+ 0.0000 G GLY
493
+ 51.600 H HIS
494
+ 0.1500 I ILE
495
+ 0.4500 L LEU
496
+ 49.500 K LYS
497
+ 1.4300 M MET
498
+ 0.3500 F PHE
499
+ 1.5800 P PRO
500
+ 1.6700 S SER
501
+ 1.6600 T THR
502
+ 2.1000 W TRP
503
+ 1.6100 Y TYR
504
+ 0.1300 V VAL
505
+ """""")
506
+
507
+ pK_side_chain = parse_property_table(""""""
508
+ 0.0000 A ALA
509
+ 12.480 R ARG
510
+ 0.0000 N ASN
511
+ 3.6500 D ASP
512
+ 8.1800 C CYS
513
+ 0.0000 Q GLN
514
+ 4.2500 E GLU
515
+ 0.0000 G GLY
516
+ 6.0000 H HIS
517
+ 0.0000 I ILE
518
+ 0.0000 L LEU
519
+ 10.530 K LYS
520
+ 0.0000 M MET
521
+ 0.0000 F PHE
522
+ 0.0000 P PRO
523
+ 0.0000 S SER
524
+ 0.0000 T THR
525
+ 0.0000 W TRP
526
+ 10.700 Y TYR
527
+ 0.0000 V VAL
528
+ """""")
529
+
530
+ prct_exposed_residues = parse_property_table(""""""
531
+ 15.0000 A ALA
532
+ 67.0000 R ARG
533
+ 49.0000 N ASN
534
+ 50.0000 D ASP
535
+ 5.00000 C CYS
536
+ 56.0000 Q GLN
537
+ 55.0000 E GLU
538
+ 10.0000 G GLY
539
+ 34.0000 H HIS
540
+ 13.0000 I ILE
541
+ 16.0000 L LEU
542
+ 85.0000 K LYS
543
+ 20.0000 M MET
544
+ 10.0000 F PHE
545
+ 45.0000 P PRO
546
+ 32.0000 S SER
547
+ 32.0000 T THR
548
+ 17.0000 W TRP
549
+ 41.0000 Y TYR
550
+ 14.0000 V VAL
551
+ """""")
552
+
553
+ hydrophilicity = parse_property_table(""""""
554
+ -0.5000 A ALA
555
+ 3.00000 R ARG
556
+ 0.20000 N ASN
557
+ 3.00000 D ASP
558
+ -1.0000 C CYS
559
+ 0.20000 Q GLN
560
+ 3.00000 E GLU
561
+ 0.00000 G GLY
562
+ -0.5000 H HIS
563
+ -1.8000 I ILE
564
+ -1.8000 L LEU
565
+ 3.00000 K LYS
566
+ -1.3000 M MET
567
+ -2.5000 F PHE
568
+ 0.00000 P PRO
569
+ 0.30000 S SER
570
+ -0.4000 T THR
571
+ -3.4000 W TRP
572
+ -2.3000 Y TYR
573
+ -1.5000 V VAL
574
+ """""")
575
+
576
+ accessible_surface_area = parse_property_table(""""""
577
+ 27.8000 A ALA
578
+ 94.7000 R ARG
579
+ 60.1000 N ASN
580
+ 60.6000 D ASP
581
+ 15.5000 C CYS
582
+ 68.7000 Q GLN
583
+ 68.2000 E GLU
584
+ 24.5000 G GLY
585
+ 50.7000 H HIS
586
+ 22.8000 I ILE
587
+ 27.6000 L LEU
588
+ 103.000 K LYS
589
+ 33.5000 M MET
590
+ 25.5000 F PHE
591
+ 51.5000 P PRO
592
+ 42.0000 S SER
593
+ 45.0000 T THR
594
+ 34.7000 W TRP
595
+ 55.2000 Y TYR
596
+ 23.7000 V VAL
597
+ """""")
598
+
599
+ local_flexibility = parse_property_table(""""""
600
+ 705.42000 A ALA
601
+ 1484.2800 R ARG
602
+ 513.46010 N ASN
603
+ 34.960000 D ASP
604
+ 2412.5601 C CYS
605
+ 1087.8300 Q GLN
606
+ 1158.6600 E GLU
607
+ 33.180000 G GLY
608
+ 1637.1300 H HIS
609
+ 5979.3701 I ILE
610
+ 4985.7300 L LEU
611
+ 699.69000 K LYS
612
+ 4491.6602 M MET
613
+ 5203.8599 F PHE
614
+ 431.96000 P PRO
615
+ 174.76000 S SER
616
+ 601.88000 T THR
617
+ 6374.0698 W TRP
618
+ 4291.1001 Y TYR
619
+ 4474.4199 V VAL
620
+ """""")
621
+
622
+ accessible_surface_area_folded = parse_property_table(""""""
623
+ 31.5000 A ALA
624
+ 93.8000 R ARG
625
+ 62.2000 N ASN
626
+ 60.9000 D ASP
627
+ 13.9000 C CYS
628
+ 74.0000 Q GLN
629
+ 72.3000 E GLU
630
+ 25.2000 G GLY
631
+ 46.7000 H HIS
632
+ 23.0000 I ILE
633
+ 29.0000 L LEU
634
+ 110.300 K LYS
635
+ 30.5000 M MET
636
+ 28.7000 F PHE
637
+ 53.7000 P PRO
638
+ 44.2000 S SER
639
+ 46.0000 T THR
640
+ 41.7000 W TRP
641
+ 59.1000 Y TYR
642
+ 23.5000 V VAL
643
+ """""")
644
+
645
+ refractivity = parse_property_table(""""""
646
+ 4.34000 A ALA
647
+ 26.6600 R ARG
648
+ 13.2800 N ASN
649
+ 12.0000 D ASP
650
+ 35.7700 C CYS
651
+ 17.5600 Q GLN
652
+ 17.2600 E GLU
653
+ 0.00000 G GLY
654
+ 21.8100 H HIS
655
+ 19.0600 I ILE
656
+ 18.7800 L LEU
657
+ 21.2900 K LYS
658
+ 21.6400 M MET
659
+ 29.4000 F PHE
660
+ 10.9300 P PRO
661
+ 6.35000 S SER
662
+ 11.0100 T THR
663
+ 42.5300 W TRP
664
+ 31.5300 Y TYR
665
+ 13.9200 V VAL
666
+ """""")
667
+
668
+
669
+ mass = parse_property_table(""""""
670
+ 70.079 A ALA
671
+ 156.188 R ARG
672
+ 114.104 N ASN
673
+ 115.089 D ASP
674
+ 103.144 C CYS
675
+ 128.131 Q GLN
676
+ 129.116 E GLU
677
+ 57.052 G GLY
678
+ 137.142 H HIS
679
+ 113.160 I ILE
680
+ 113.160 L LEU
681
+ 128.174 K LYS
682
+ 131.198 M MET
683
+ 147.177 F PHE
684
+ 97.177 P PRO
685
+ 87.078 S SER
686
+ 101.105 T THR
687
+ 186.213 W TRP
688
+ 163.170 Y TYR
689
+ 99.133 V VAL
690
+ """""")
691
+
692
+ ###
693
+ # Values copied from:
694
+ # ""Solvent accessibility of AA in known protein structures""
695
+ # http://prowl.rockefeller.edu/aainfo/access.htm
696
+ ###
697
+ """"""
698
+ Solvent accessibility of AA in known protein structures
699
+
700
+ Figure 1.
701
+
702
+ S 0.70 0.20 0.10
703
+ T 0.71 0.16 0.13
704
+ A 0.48 0.35 0.17
705
+ G 0.51 0.36 0.13
706
+ P 0.78 0.13 0.09
707
+ C 0.32 0.54 0.14
708
+ D 0.81 0.09 0.10
709
+ E 0.93 0.04 0.03
710
+ Q 0.81 0.10 0.09
711
+ N 0.82 0.10 0.08
712
+ L 0.41 0.49 0.10
713
+ I 0.39 0.47 0.14
714
+ V 0.40 0.50 0.10
715
+ M 0.44 0.20 0.36
716
+ F 0.42 0.42 0.16
717
+ Y 0.67 0.20 0.13
718
+ W 0.49 0.44 0.07
719
+ K 0.93 0.02 0.05
720
+ R 0.84 0.05 0.11
721
+ H 0.66 0.19 0.15
722
+ """"""
723
+
724
+ solvent_exposed_area = dict(
725
+ S=0.70,
726
+ T=0.71,
727
+ A=0.48,
728
+ G=0.51,
729
+ P=0.78,
730
+ C=0.32,
731
+ D=0.81,
732
+ E=0.93,
733
+ Q=0.81,
734
+ N=0.82,
735
+ L=0.41,
736
+ I=0.39,
737
+ V=0.40,
738
+ M=0.44,
739
+ F=0.42,
740
+ Y=0.67,
741
+ W=0.49,
742
+ K=0.93,
743
+ R=0.84,
744
+ H=0.66,
745
+ )
746
+ ","Python"
747
+ "Hydrophilic","openvax/pepdata","pepdata/reduced_alphabet.py",".py","1784","58","# Copyright (c) 2014-2018. Mount Sinai School of Medicine
748
+ #
749
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
750
+ # you may not use this file except in compliance with the License.
751
+ # You may obtain a copy of the License at
752
+ #
753
+ # http://www.apache.org/licenses/LICENSE-2.0
754
+ #
755
+ # Unless required by applicable law or agreed to in writing, software
756
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
757
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
758
+ # See the License for the specific language governing permissions and
759
+ # limitations under the License.
760
+
761
+ """"""
762
+ Amino acid groupings from
763
+ 'Reduced amino acid alphabets improve the sensitivity...' by
764
+ Peterson, Kondev, et al.
765
+ http://www.rpgroup.caltech.edu/publications/Peterson2008.pdf
766
+ """"""
767
+ from __future__ import print_function, division, absolute_import
768
+
769
+ def dict_from_list(groups):
770
+ aa_to_group = {}
771
+ for i, group in enumerate(groups):
772
+ for c in group:
773
+ aa_to_group[c] = group[0]
774
+ return aa_to_group
775
+
776
+ gbmr4 = dict_from_list([""ADKERNTSQ"", ""YFLIVMCWH"", ""G"", ""P""])
777
+
778
+ sdm12 = dict_from_list([
779
+ ""A"", ""D"", ""KER"", ""N"", ""TSQ"", ""YF"", ""LIVM"", ""C"", ""W"", ""H"", ""G"", ""P""
780
+ ])
781
+
782
+ hsdm17 = dict_from_list([
783
+ ""A"", ""D"", ""KE"", ""R"", ""N"", ""T"", ""S"", ""Q"", ""Y"",
784
+ ""F"", ""LIV"", ""M"", ""C"", ""W"", ""H"", ""G"", ""P""
785
+ ])
786
+
787
+ """"""
788
+ Other alphabets from
789
+ http://bio.math-inf.uni-greifswald.de/viscose/html/alphabets.html
790
+ """"""
791
+
792
+ # hydrophilic vs. hydrophobic
793
+ hp2 = dict_from_list([""AGTSNQDEHRKP"", ""CMFILVWY""])
794
+
795
+ murphy10 = dict_from_list([
796
+ ""LVIM"", ""C"", ""A"", ""G"", ""ST"", ""P"", ""FYW"", ""EDNQ"", ""KR"", ""H""
797
+ ])
798
+
799
+ alex6 = dict_from_list([""C"", ""G"", ""P"", ""FYW"", ""AVILM"", ""STNQRHKDE""])
800
+
801
+ aromatic2 = dict_from_list([""FHWY"", ""ADKERNTSQLIVMCGP""])
802
+
803
+ hp_vs_aromatic = dict_from_list([""H"", ""CMILV"", ""FWY"", ""ADKERNTSQGP""])
804
+ ","Python"
805
+ "Hydrophilic","openvax/pepdata","pepdata/peptide_vectorizer.py",".py","2942","84","# Copyright (c) 2014-2016. Mount Sinai School of Medicine
806
+ #
807
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
808
+ # you may not use this file except in compliance with the License.
809
+ # You may obtain a copy of the License at
810
+ #
811
+ # http://www.apache.org/licenses/LICENSE-2.0
812
+ #
813
+ # Unless required by applicable law or agreed to in writing, software
814
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
815
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
816
+ # See the License for the specific language governing permissions and
817
+ # limitations under the License.
818
+
819
+
820
+ from __future__ import print_function, division, absolute_import
821
+
822
+ import numpy as np
823
+ from sklearn.feature_extraction.text import CountVectorizer
824
+ from sklearn.preprocessing import normalize
825
+
826
+ def make_count_vectorizer(reduced_alphabet, max_ngram):
827
+ if reduced_alphabet is None:
828
+ preprocessor = None
829
+ else:
830
+ preprocessor = lambda s: """".join([reduced_alphabet[si] for si in s])
831
+
832
+ return CountVectorizer(
833
+ analyzer='char',
834
+ ngram_range=(1, max_ngram),
835
+ dtype=np.float,
836
+ preprocessor=preprocessor)
837
+
838
+ class PeptideVectorizer(object):
839
+ """"""
840
+ Make n-gram frequency vectors from peptide sequences
841
+ """"""
842
+ def __init__(
843
+ self,
844
+ max_ngram=1,
845
+ normalize_row=True,
846
+ reduced_alphabet=None,
847
+ training_already_reduced=False):
848
+ self.reduced_alphabet = reduced_alphabet
849
+ self.max_ngram = max_ngram
850
+ self.normalize_row = normalize_row
851
+ self.training_already_reduced = training_already_reduced
852
+ self.count_vectorizer = None
853
+
854
+ def __getstate__(self):
855
+ return {
856
+ 'reduced_alphabet': self.reduced_alphabet,
857
+ 'count_vectorizer': self.count_vectorizer,
858
+ 'training_already_reduced': self.training_already_reduced,
859
+ 'normalize_row': self.normalize_row,
860
+ 'max_ngram': self.max_ngram,
861
+ }
862
+
863
+ def fit_transform(self, amino_acid_strings):
864
+ self.count_vectorizer = \
865
+ make_count_vectorizer(self.reduced_alphabet, self.max_ngram)
866
+
867
+ if self.training_already_reduced:
868
+ c = make_count_vectorizer(None, self.max_ngram)
869
+ X = c.fit_transform(amino_acid_strings).todense()
870
+ self.count_vectorizer.vocabulary_ = c.vocabulary_
871
+ else:
872
+ c = self.count_vectorizer
873
+ X = c.fit_transform(amino_acid_strings).todense()
874
+
875
+ if self.normalize_row:
876
+ X = normalize(X, norm='l1')
877
+ return X
878
+
879
+ def fit(self, amino_acid_strings):
880
+ self.fit_transform(amino_acid_strings)
881
+
882
+ def transform(self, amino_acid_strings):
883
+ assert self.count_vectorizer, ""Must call 'fit' before 'transform'""
884
+ X = self.count_vectorizer.transform(amino_acid_strings).todense()
885
+ if self.normalize_row:
886
+ X = normalize(X, norm='l1')
887
+ return X
888
+ ","Python"
889
+ "Hydrophilic","openvax/pepdata","pepdata/chou_fasman.py",".py","3279","75","# Licensed under the Apache License, Version 2.0 (the ""License"");
890
+ # you may not use this file except in compliance with the License.
891
+ # You may obtain a copy of the License at
892
+ #
893
+ # http://www.apache.org/licenses/LICENSE-2.0
894
+ #
895
+ # Unless required by applicable law or agreed to in writing, software
896
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
897
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
898
+ # See the License for the specific language governing permissions and
899
+ # limitations under the License.
900
+
901
+ from __future__ import print_function, division, absolute_import
902
+
903
+ from .amino_acid_alphabet import amino_acid_name_indices
904
+
905
+ # Chou-Fasman of structural properties from
906
+ # http://prowl.rockefeller.edu/aainfo/chou.htm
907
+ chou_fasman_table = """"""
908
+ Alanine 142 83 66 0.06 0.076 0.035 0.058
909
+ Arginine 98 93 95 0.070 0.106 0.099 0.085
910
+ Aspartic Acid 101 54 146 0.147 0.110 0.179 0.081
911
+ Asparagine 67 89 156 0.161 0.083 0.191 0.091
912
+ Cysteine 70 119 119 0.149 0.050 0.117 0.128
913
+ Glutamic Acid 151 037 74 0.056 0.060 0.077 0.064
914
+ Glutamine 111 110 98 0.074 0.098 0.037 0.098
915
+ Glycine 57 75 156 0.102 0.085 0.190 0.152
916
+ Histidine 100 87 95 0.140 0.047 0.093 0.054
917
+ Isoleucine 108 160 47 0.043 0.034 0.013 0.056
918
+ Leucine 121 130 59 0.061 0.025 0.036 0.070
919
+ Lysine 114 74 101 0.055 0.115 0.072 0.095
920
+ Methionine 145 105 60 0.068 0.082 0.014 0.055
921
+ Phenylalanine 113 138 60 0.059 0.041 0.065 0.065
922
+ Proline 57 55 152 0.102 0.301 0.034 0.068
923
+ Serine 77 75 143 0.120 0.139 0.125 0.106
924
+ Threonine 83 119 96 0.086 0.108 0.065 0.079
925
+ Tryptophan 108 137 96 0.077 0.013 0.064 0.167
926
+ Tyrosine 69 147 114 0.082 0.065 0.114 0.125
927
+ Valine 106 170 50 0.062 0.048 0.028 0.053
928
+ """"""
929
+
930
+
931
+ def parse_chou_fasman(table):
932
+ alpha_helix_score_dict = {}
933
+ beta_sheet_score_dict = {}
934
+ turn_score_dict = {}
935
+
936
+ for line in table.split(""\n""):
937
+ fields = [field for field in line.split("" "") if len(field.strip()) > 0]
938
+ if len(fields) == 0:
939
+ continue
940
+
941
+ if fields[1] == 'Acid':
942
+ name = fields[0] + "" "" + fields[1]
943
+ fields = fields[1:]
944
+ else:
945
+ name = fields[0]
946
+
947
+ assert name in amino_acid_name_indices, ""Invalid amino acid name %s"" % name
948
+ letter = amino_acid_name_indices[name]
949
+ alpha = int(fields[1])
950
+ beta = int(fields[2])
951
+ turn = int(fields[3])
952
+ alpha_helix_score_dict[letter] = alpha
953
+ beta_sheet_score_dict[letter] = beta
954
+ turn_score_dict[letter] = turn
955
+
956
+ assert len(alpha_helix_score_dict) == 20
957
+ assert len(beta_sheet_score_dict) == 20
958
+ assert len(turn_score_dict) == 20
959
+ return alpha_helix_score_dict, beta_sheet_score_dict, turn_score_dict
960
+
961
+ alpha_helix_score, beta_sheet_score, turn_score = \
962
+ parse_chou_fasman(chou_fasman_table)
963
+ ","Python"
964
+ "Hydrophilic","openvax/pepdata","pepdata/pmbec.py",".py","3019","89","# Copyright (c) 2014-2016. Mount Sinai School of Medicine
965
+ #
966
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
967
+ # you may not use this file except in compliance with the License.
968
+ # You may obtain a copy of the License at
969
+ #
970
+ # http://www.apache.org/licenses/LICENSE-2.0
971
+ #
972
+ # Unless required by applicable law or agreed to in writing, software
973
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
974
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
975
+ # See the License for the specific language governing permissions and
976
+ # limitations under the License.
977
+
978
+ from __future__ import print_function, division, absolute_import
979
+ from os.path import join
980
+
981
+ from .static_data import MATRIX_DIR
982
+
983
+ from .amino_acid_alphabet import dict_to_amino_acid_matrix
984
+
985
+ def read_pmbec_coefficients(
986
+ key_type='row',
987
+ verbose=True,
988
+ filename=join(MATRIX_DIR, 'pmbec.mat')):
989
+ """"""
990
+ Parameters
991
+ ------------
992
+
993
+ filename : str
994
+ Location of PMBEC coefficient matrix
995
+
996
+ key_type : str
997
+ 'row' : every key is a single amino acid,
998
+ which maps to a dictionary for that row
999
+ 'pair' : every key is a tuple of amino acids
1000
+ 'pair_string' : every key is a string of two amino acid characters
1001
+
1002
+ verbose : bool
1003
+ Print rows of matrix as we read them
1004
+ """"""
1005
+ d = {}
1006
+ if key_type == 'row':
1007
+ def add_pair(row_letter, col_letter, value):
1008
+ if row_letter not in d:
1009
+ d[row_letter] = {}
1010
+ d[row_letter][col_letter] = value
1011
+ elif key_type == 'pair':
1012
+ def add_pair(row_letter, col_letter, value):
1013
+ d[(row_letter, col_letter)] = value
1014
+
1015
+ else:
1016
+ assert key_type == 'pair_string', \
1017
+ ""Invalid dictionary key type: %s"" % key_type
1018
+
1019
+ def add_pair(row_letter, col_letter, value):
1020
+ d[""%s%s"" % (row_letter, col_letter)] = value
1021
+
1022
+ with open(filename, 'r') as f:
1023
+ lines = [line for line in f.read().split('\n') if len(line) > 0]
1024
+ header = lines[0]
1025
+ if verbose:
1026
+ print(header)
1027
+ residues = [
1028
+ x for x in header.split()
1029
+ if len(x) == 1 and x != ' ' and x != '\t'
1030
+ ]
1031
+ assert len(residues) == 20
1032
+ if verbose:
1033
+ print(residues)
1034
+ for line in lines[1:]:
1035
+ cols = [
1036
+ x
1037
+ for x in line.split(' ')
1038
+ if len(x) > 0 and x != ' ' and x != '\t'
1039
+ ]
1040
+ assert len(cols) == 21, ""Expected 20 values + letter, got %s"" % cols
1041
+ row_letter = cols[0]
1042
+ for i, col in enumerate(cols[1:]):
1043
+ col_letter = residues[i]
1044
+ assert col_letter != ' ' and col_letter != '\t'
1045
+ value = float(col)
1046
+ add_pair(row_letter, col_letter, value)
1047
+ return d
1048
+
1049
+ # dictionary of PMBEC coefficient accessed like pmbec_dict[""V""][""R""]
1050
+ pmbec_dict = read_pmbec_coefficients(key_type=""row"")
1051
+ pmbec_matrix = dict_to_amino_acid_matrix(pmbec_dict)
1052
+ ","Python"
1053
+ "Hydrophilic","openvax/pepdata","pepdata/residue_contact_energies.py",".py","2937","77","# Licensed under the Apache License, Version 2.0 (the ""License"");
1054
+ # you may not use this file except in compliance with the License.
1055
+ # You may obtain a copy of the License at
1056
+ #
1057
+ # http://www.apache.org/licenses/LICENSE-2.0
1058
+ #
1059
+ # Unless required by applicable law or agreed to in writing, software
1060
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1061
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1062
+ # See the License for the specific language governing permissions and
1063
+ # limitations under the License.
1064
+
1065
+ from __future__ import print_function, division, absolute_import
1066
+
1067
+ from os.path import join
1068
+
1069
+ from .amino_acid_alphabet import canonical_amino_acid_letters, dict_to_amino_acid_matrix
1070
+ from .static_data import MATRIX_DIR
1071
+
1072
+
1073
+ def parse_interaction_table(table, amino_acid_order=""ARNDCQEGHILKMFPSTWYV""):
1074
+ table = table.strip()
1075
+ while "" "" in table:
1076
+ table = table.replace("" "", "" "")
1077
+
1078
+ lines = [l.strip() for l in table.split(""\n"")]
1079
+ lines = [l for l in lines if len(l) > 0 and not l.startswith(""#"")]
1080
+ assert len(lines) == 20, ""Malformed amino acid interaction table""
1081
+ d = {}
1082
+ for i, line in enumerate(lines):
1083
+ coeff_strings = line.split("" "")
1084
+ assert len(coeff_strings) == 20, \
1085
+ ""Malformed row in amino acid interaction table""
1086
+ x = amino_acid_order[i]
1087
+ d[x] = {}
1088
+ for j, coeff_str in enumerate(coeff_strings):
1089
+ value = float(coeff_str)
1090
+ y = amino_acid_order[j]
1091
+ d[x][y] = value
1092
+ return d
1093
+
1094
+ def transpose_interaction_dict(d):
1095
+ transposed = {}
1096
+ for x in canonical_amino_acid_letters:
1097
+ transposed[x] = {}
1098
+ for y in canonical_amino_acid_letters:
1099
+ transposed[x][y] = d[y][x]
1100
+ return transposed
1101
+
1102
+
1103
+ with open(join(MATRIX_DIR, 'strand_vs_coil.txt'), 'r') as f:
1104
+ # Strand vs. Coil
1105
+ strand_vs_coil_dict = parse_interaction_table(f.read())
1106
+ strand_vs_coil_array = dict_to_amino_acid_matrix(strand_vs_coil_dict)
1107
+
1108
+ # Coil vs. Strand
1109
+ coil_vs_strand_dict = transpose_interaction_dict(strand_vs_coil_dict)
1110
+ coil_vs_strand_array = dict_to_amino_acid_matrix(coil_vs_strand_dict)
1111
+
1112
+ with open(join(MATRIX_DIR, 'helix_vs_strand.txt'), 'r') as f:
1113
+ # Helix vs. Strand
1114
+ helix_vs_strand_dict = parse_interaction_table(f.read())
1115
+ helix_vs_strand_array = dict_to_amino_acid_matrix(helix_vs_strand_dict)
1116
+
1117
+ # Strand vs. Helix
1118
+ strand_vs_helix_dict = transpose_interaction_dict(helix_vs_strand_dict)
1119
+ strand_vs_helix_array = dict_to_amino_acid_matrix(strand_vs_helix_dict)
1120
+
1121
+ with open(join(MATRIX_DIR, 'helix_vs_coil.txt'), 'r') as f:
1122
+ # Helix vs. Coil
1123
+ helix_vs_coil_dict = parse_interaction_table(f.read())
1124
+ helix_vs_coil_array = dict_to_amino_acid_matrix(helix_vs_coil_dict)
1125
+
1126
+ # Coil vs. Helix
1127
+ coil_vs_helix_dict = transpose_interaction_dict(helix_vs_coil_dict)
1128
+ coil_vs_helix_array = dict_to_amino_acid_matrix(coil_vs_helix_dict)
1129
+ ","Python"
1130
+ "Hydrophilic","openvax/pepdata","pepdata/blosum.py",".py","2600","76","# Licensed under the Apache License, Version 2.0 (the ""License"");
1131
+ # you may not use this file except in compliance with the License.
1132
+ # You may obtain a copy of the License at
1133
+ #
1134
+ # http://www.apache.org/licenses/LICENSE-2.0
1135
+ #
1136
+ # Unless required by applicable law or agreed to in writing, software
1137
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1138
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139
+ # See the License for the specific language governing permissions and
1140
+ # limitations under the License.
1141
+
1142
+ from __future__ import print_function, division, absolute_import
1143
+
1144
+ from os.path import join
1145
+
1146
+ from .static_data import MATRIX_DIR
1147
+
1148
+ from .amino_acid_alphabet import dict_to_amino_acid_matrix
1149
+
1150
+ def parse_blosum_table(table, coeff_type=int, key_type='row'):
1151
+ """"""
1152
+ Parse a table of pairwise amino acid coefficient (e.g. BLOSUM50)
1153
+ """"""
1154
+
1155
+ lines = table.split(""\n"")
1156
+ # drop comments
1157
+ lines = [line for line in lines if not line.startswith(""#"")]
1158
+ # drop CR endline characters
1159
+ lines = [line.replace(""\r"", """") for line in lines]
1160
+ # skip empty lines
1161
+ lines = [line for line in lines if line]
1162
+
1163
+ labels = lines[0].split()
1164
+
1165
+ if len(labels) < 20:
1166
+ raise ValueError(
1167
+ ""Expected 20+ amino acids but first line '%s' has %d fields"" % (
1168
+ lines[0],
1169
+ len(labels)))
1170
+ coeffs = {}
1171
+ for line in lines[1:]:
1172
+
1173
+ fields = line.split()
1174
+ assert len(fields) >= 21, \
1175
+ ""Expected AA and 20+ coefficients but '%s' has %d fields"" % (
1176
+ line, len(fields))
1177
+ x = fields[0]
1178
+ for i, coeff_str in enumerate(fields[1:]):
1179
+ y = labels[i]
1180
+ coeff = coeff_type(coeff_str)
1181
+ if key_type == 'pair':
1182
+ coeffs[(x, y)] = coeff
1183
+ elif key_type == 'pair_string':
1184
+ coeffs[x + y] = coeff
1185
+ else:
1186
+ assert key_type == 'row', ""Unknown key type: %s"" % key_type
1187
+ if x not in coeffs:
1188
+ coeffs[x] = {}
1189
+ coeffs[x][y] = coeff
1190
+ return coeffs
1191
+
1192
+
1193
+ with open(join(MATRIX_DIR, 'BLOSUM30'), 'r') as f:
1194
+ blosum30_dict = parse_blosum_table(f.read())
1195
+ blosum30_matrix = dict_to_amino_acid_matrix(blosum30_dict)
1196
+
1197
+ with open(join(MATRIX_DIR, 'BLOSUM50'), 'r') as f:
1198
+ blosum50_dict = parse_blosum_table(f.read())
1199
+ blosum50_matrix = dict_to_amino_acid_matrix(blosum50_dict)
1200
+
1201
+ with open(join(MATRIX_DIR, 'BLOSUM62'), 'r') as f:
1202
+ blosum62_dict = parse_blosum_table(f.read())
1203
+ blosum62_matrix = dict_to_amino_acid_matrix(blosum62_dict)
1204
+
1205
+ ","Python"
1206
+ "Hydrophilic","openvax/pepdata","pepdata/matrices/__init__.py",".py","0","0","","Python"
1207
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/columns.py",".py","6767","177","# Licensed under the Apache License, Version 2.0 (the ""License"");
1208
+ # you may not use this file except in compliance with the License.
1209
+ # You may obtain a copy of the License at
1210
+ #
1211
+ # http://www.apache.org/licenses/LICENSE-2.0
1212
+ #
1213
+ # Unless required by applicable law or agreed to in writing, software
1214
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1215
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1216
+ # See the License for the specific language governing permissions and
1217
+ # limitations under the License.
1218
+
1219
+ from __future__ import annotations
1220
+
1221
+
1222
+ import pandas as pd
1223
+
1224
+ def find(df : pd.DataFrame, group_candidates : list[str], column_candidates : list[str]) -> pd.Series | None:
1225
+ """"""
1226
+ Try to find a column that contains a combination of the two candidate lists.
1227
+
1228
+ Motivation: format for MHC ligand CSV used to have:
1229
+ epitope_key = (""Epitope"", ""Description"")
1230
+ mhc_allele_key = (""MHC"", ""Allele Name"")
1231
+ mhc_class_key = (""MHC"", ""MHC allele class"")
1232
+ mhc_assay_key = (""Assay"", ""Method/Technique"")
1233
+
1234
+ Now it's:
1235
+ epitope_key = (""Epitope"", ""Name"")
1236
+ mhc_allele_key = (""MHC Restriction"", ""Name"")
1237
+ mhc_class_key = (""MHC Restriction"", ""Class"")
1238
+ mhc_assay_key = (""Assay"", ""Method"")
1239
+
1240
+ ...who knows what it will be next!
1241
+ """"""
1242
+ group_candidates = [s.lower() for s in group_candidates]
1243
+ column_candidates = [s.lower() for s in column_candidates]
1244
+
1245
+ possible_matches = []
1246
+ for a in group_candidates:
1247
+ for b in column_candidates:
1248
+ for pair in df.columns:
1249
+ assert type(pair) is tuple and len(pair) == 2
1250
+ group, col = pair
1251
+ if a in group.lower() and b in col.lower():
1252
+ possible_matches.append(pair)
1253
+
1254
+ if len(possible_matches) == 0:
1255
+ return None
1256
+ # get the shortest matches
1257
+
1258
+
1259
+
1260
+ MHC_GROUP_CANDIDATES : list[str] = [""MHC"", ""MHC Restriction""]
1261
+ EPITOPE_GROUP_CANDIDATES : list[str] = [""Epitope""]
1262
+ ASSAY_GROUP_CANDIDATES : list[str] = [""Assay""]
1263
+ HOST_GROUP_CANDIDATES : list[str] = [""Host""]
1264
+
1265
+ def get_mhc_allele(
1266
+ df : pd.DataFrame,
1267
+ group_candidates : list[str] = MHC_GROUP_CANDIDATES,
1268
+ column_candidates : list[str] = [""Allele"", ""Allele name"", ""Name""]) -> pd.Series | None:
1269
+ return find(df, group_candidates, column_candidates)
1270
+
1271
+
1272
+ def get_mhc_class(
1273
+ df : pd.DataFrame,
1274
+ group_candidates : list[str] = MHC_GROUP_CANDIDATES,
1275
+ column_candidates : list[str] =[""Class"", ""MHC allele class""]) -> pd.Series | None:
1276
+ return find(df, group_candidates, column_candidates)
1277
+
1278
+
1279
+ def get_mhc_assay(
1280
+ df : pd.Series,
1281
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1282
+ column_candidates : list[str] =[""method""]) -> pd.Series | None:
1283
+ return find(df, group_candidates, column_candidates)
1284
+
1285
+
1286
+ def get_epitope_name(
1287
+ df : pd.DataFrame,
1288
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1289
+ column_candidates : list[str] =[""name""]) -> pd.Series | None:
1290
+ return find(df, group_candidates, column_candidates)
1291
+
1292
+
1293
+ def get_epitope_type(
1294
+ df : pd.DataFrame,
1295
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1296
+ column_candidates : list[str] =[""Object Type"", ""Type""]) -> pd.Series | None:
1297
+ return find(df, group_candidates, column_candidates)
1298
+
1299
+ def get_epitope_modifications(
1300
+ df : pd.DataFrame,
1301
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1302
+ column_candidates : list[str] = [""Modified Residue(s)""]) -> pd.Series | None:
1303
+ return find(df, group_candidates, column_candidates)
1304
+
1305
+
1306
+ def get_epitope_IRI(
1307
+ df : pd.DataFrame,
1308
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1309
+ column_candidates : list[str] =[""Epitope IRI""]) -> pd.Series | None:
1310
+ return find(df, group_candidates, column_candidates)
1311
+
1312
+
1313
+ def get_epitope_source_molecule(
1314
+ df : pd.DataFrame,
1315
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1316
+ column_candidates=[""Source Molecule""]) -> pd.Series | None:
1317
+ return find(df, group_candidates, column_candidates)
1318
+
1319
+ def get_epitope_source_molecule_iri(
1320
+ df : pd.DataFrame,
1321
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1322
+ column_candidates : list[str] = [""Source Molecule IRI""]) -> pd.Series | None:
1323
+ return find(df, group_candidates, column_candidates)
1324
+
1325
+
1326
+ def get_epitope_source_organism(
1327
+ df : pd.DataFrame,
1328
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1329
+ column_candidates : list[str] = [""Source Organism""]) -> pd.Series | None:
1330
+ return find(df, group_candidates, column_candidates)
1331
+
1332
+
1333
+ def get_epitope_source_organism_iri(
1334
+ df : pd.DataFrame,
1335
+ group_candidates : list[str] = EPITOPE_GROUP_CANDIDATES,
1336
+ column_candidates : list[str] = [""Source Organism IRI""]) -> pd.Series | None:
1337
+ return find(df, group_candidates, column_candidates)
1338
+
1339
+ def get_assay_method(
1340
+ df : pd.DataFrame,
1341
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1342
+ column_candidates : list[str] = [""Method"", ""Method/Technique""]) -> pd.Series | None:
1343
+ return find(df, group_candidates, column_candidates)
1344
+
1345
+ def get_assay_response_measured(
1346
+ df : pd.DataFrame,
1347
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1348
+ column_candidates : list[str] = [""Response measured""]) -> pd.Series | None:
1349
+ return find(df, group_candidates, column_candidates)
1350
+
1351
+
1352
+ def get_assay_units(
1353
+ df : pd.DataFrame,
1354
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1355
+ column_candidates : list[str] = [""Units""]) -> pd.Series | None:
1356
+ return find(df, group_candidates, column_candidates)
1357
+
1358
+
1359
+ def get_assay_qualitative(
1360
+ df : pd.DataFrame,
1361
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1362
+ column_candidates : list[str] = [""Qualitative Measurement""]) -> pd.Series | None:
1363
+ return find(df, group_candidates, column_candidates)
1364
+
1365
+ def get_assay_num_tested(
1366
+ df : pd.DataFrame,
1367
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1368
+ column_candidates : list[str] = [""Number of Subjects Tested""]) -> pd.Series | None:
1369
+ return find(df, group_candidates, column_candidates)
1370
+
1371
+ def get_assay_num_responded(
1372
+ df : pd.DataFrame,
1373
+ group_candidates : list[str] = ASSAY_GROUP_CANDIDATES,
1374
+ column_candidates : list[str] = [""Number of Subjects Responded""]) -> pd.Series | None:
1375
+ return find(df, group_candidates, column_candidates)
1376
+
1377
+
1378
+ def get_host_name(
1379
+ df : pd.DataFrame,
1380
+ group_candidates : list[str] = HOST_GROUP_CANDIDATES,
1381
+ column_candidates : list[str] = [""Name""]) -> pd.Series | None:
1382
+ return find(df, group_candidates, column_candidates)
1383
+ ","Python"
1384
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/mhc.py",".py","5123","165","# Licensed under the Apache License, Version 2.0 (the ""License"");
1385
+ # you may not use this file except in compliance with the License.
1386
+ # You may obtain a copy of the License at
1387
+ #
1388
+ # http://www.apache.org/licenses/LICENSE-2.0
1389
+ #
1390
+ # Unless required by applicable law or agreed to in writing, software
1391
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1392
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1393
+ # See the License for the specific language governing permissions and
1394
+ # limitations under the License.
1395
+
1396
+ from __future__ import print_function, division, absolute_import
1397
+ import logging
1398
+ import os
1399
+
1400
+ import pandas as pd
1401
+
1402
+ from .memoize import memoize
1403
+ from .common import bad_amino_acids, cache
1404
+
1405
+
1406
+ MHC_URL = ""https://www.iedb.org/downloader.php?file_name=doc/mhc_ligand_full_single_file.zip""
1407
+ MHC_LOCAL_FILENAME = ""mhc_ligand_full.csv""
1408
+ MHC_DECOMPRESS = True
1409
+
1410
+ def download(force=False):
1411
+ return cache.fetch(
1412
+ filename=MHC_LOCAL_FILENAME,
1413
+ url=MHC_URL,
1414
+ decompress=MHC_DECOMPRESS,
1415
+ force=force)
1416
+
1417
+ def local_path(auto_download=True):
1418
+ path = cache.local_path(
1419
+ filename=MHC_LOCAL_FILENAME,
1420
+ url=MHC_URL,
1421
+ decompress=MHC_DECOMPRESS)
1422
+ if not os.path.exists(path):
1423
+ if auto_download:
1424
+ return download()
1425
+ raise ValueError(
1426
+ (""MHC data file %s does not exist locally,""
1427
+ "" call pepdata.mhc.download() to get a copy from IEDB"") % path)
1428
+ return path
1429
+
1430
+ def delete():
1431
+ os.remove(local_path())
1432
+
1433
+ @memoize
1434
+ def load_dataframe(
1435
+ mhc_class : int | None = None, # 1, 2, or None for neither
1436
+ hla : str | None = None,
1437
+ exclude_hla : str | None = None,
1438
+ human_only : bool = False,
1439
+ peptide_length : int | None = None,
1440
+ assay_method : str | None = None,
1441
+ only_standard_amino_acids : bool = True,
1442
+ warn_bad_lines : bool = True,
1443
+ nrows : int | None = None):
1444
+ """"""
1445
+ Load IEDB MHC data without aggregating multiple entries for the same epitope
1446
+
1447
+ Parameters
1448
+ ----------
1449
+ mhc_class
1450
+ Restrict to MHC Class I or Class II (or None for neither)
1451
+
1452
+ hla
1453
+ Restrict results to specific HLA type used in assay (regex pattern)
1454
+
1455
+ exclude_hla
1456
+ Regex pattern to exclude certain HLA types
1457
+
1458
+ human_only
1459
+ Restrict to human samples (default False)
1460
+
1461
+ peptide_length
1462
+ Restrict epitopes to amino acid strings of given length
1463
+
1464
+ assay_method
1465
+ Limit to assay methods which contain the given string
1466
+
1467
+ only_standard_amino_acids
1468
+ Drop sequences which use non-standard amino acids, anything outside
1469
+ the core 20, such as X or U (default = True)
1470
+
1471
+ warn_bad_lines
1472
+ The full MHC ligand dataset seems to contain several dozen lines with
1473
+ too many fields. This currently results in a lot of warning messages
1474
+ from Pandas, which you can turn off with this option (default = True)
1475
+
1476
+ nrows
1477
+ Don't load the full IEDB dataset but instead read only the first nrows
1478
+ """"""
1479
+ df = pd.read_csv(
1480
+ local_path(),
1481
+ header=[0, 1],
1482
+ skipinitialspace=True,
1483
+ nrows=nrows,
1484
+ low_memory=False,
1485
+ on_bad_lines='warn' if warn_bad_lines else 'skip',
1486
+ encoding=""latin-1"")
1487
+
1488
+ # Sometimes the IEDB seems to put in an extra comma in the
1489
+ # header line, which creates an unnamed column of NaNs.
1490
+ # To deal with this, drop any columns which are all NaN
1491
+ df = df.dropna(axis=1, how=""all"")
1492
+
1493
+ print(df.head())
1494
+
1495
+ n = len(df)
1496
+
1497
+ mhc_group_key = ""MHC Restriction""
1498
+ epitope_group_key = ""Epitope""
1499
+ epitope_column_key = (epitope_group_key, ""Name"")
1500
+
1501
+ mhc_allele_column_key = (mhc_group_key, ""Name"")
1502
+
1503
+ epitopes = df[epitope_column_key] = df[epitope_column_key].str.upper()
1504
+
1505
+ null_epitope_seq = epitopes.isnull()
1506
+ n_null = null_epitope_seq.sum()
1507
+ if n_null > 0:
1508
+ logging.info(""Dropping %d null sequences"", n_null)
1509
+
1510
+ mask = ~null_epitope_seq
1511
+
1512
+ if only_standard_amino_acids:
1513
+ # if have rare or unknown amino acids, drop the sequence
1514
+ bad_epitope_seq = \
1515
+ epitopes.str.contains(bad_amino_acids, na=False).astype(""bool"")
1516
+ n_bad = bad_epitope_seq.sum()
1517
+ if n_bad > 0:
1518
+ logging.info(""Dropping %d bad sequences"", n_bad)
1519
+
1520
+ mask &= ~bad_epitope_seq
1521
+
1522
+ if human_only:
1523
+ mask &= df[mhc_allele_column_key].str.startswith(""HLA"").astype(""bool"")
1524
+
1525
+ if mhc_class == 1:
1526
+ mask &= df[mhc_group_key][""Class""] == ""I""
1527
+ elif mhc_class == 2:
1528
+ mask &= df[mhc_group_key][""Class""] == ""II""
1529
+
1530
+ if hla:
1531
+ mask &= df[mhc_allele_column_key].str.contains(hla, na=False)
1532
+
1533
+ if exclude_hla:
1534
+ mask &= ~(df[mhc_allele_column_key].str.contains(exclude_hla, na=False))
1535
+
1536
+ if assay_method:
1537
+ mask &= df[""Assay""][""Method""].str.contains(assay_method)
1538
+
1539
+ if peptide_length:
1540
+ assert peptide_length > 0
1541
+ mask &= df[epitope_column_key].str.len() == peptide_length
1542
+
1543
+ df = df[mask].copy()
1544
+
1545
+ logging.info(""Returning %d / %d entries after filtering"", len(df), n)
1546
+
1547
+ return df
1548
+ ","Python"
1549
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/alleles.py",".py","3257","104","# Licensed under the Apache License, Version 2.0 (the ""License"");
1550
+ # you may not use this file except in compliance with the License.
1551
+ # You may obtain a copy of the License at
1552
+ #
1553
+ # http://www.apache.org/licenses/LICENSE-2.0
1554
+ #
1555
+ # Unless required by applicable law or agreed to in writing, software
1556
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1557
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1558
+ # See the License for the specific language governing permissions and
1559
+ # limitations under the License.
1560
+
1561
+ from __future__ import print_function, division, absolute_import
1562
+ from collections import namedtuple
1563
+ import os
1564
+ import xml
1565
+
1566
+ from .common import cache
1567
+ from .memoize import memoize
1568
+
1569
+ ALLELE_XML_FILENAME = ""MhcAlleleNames.xml""
1570
+ ALLELE_XML_URL = ""http://www.iedb.org/doc/MhcAlleleNameList.zip""
1571
+ ALLELE_XML_DECOMPRESS = True
1572
+
1573
+ def local_path(force_download=False):
1574
+ """"""Downloads allele database from IEDB, returns local path to XML file.""""""
1575
+ return cache.fetch(
1576
+ filename=ALLELE_XML_FILENAME,
1577
+ url=ALLELE_XML_URL,
1578
+ decompress=ALLELE_XML_DECOMPRESS,
1579
+ force=force_download)
1580
+
1581
+ def delete():
1582
+ """"""Deletes local XML file""""""
1583
+ path = cache.local_path(
1584
+ filename=ALLELE_XML_FILENAME,
1585
+ url=ALLELE_XML_URL,
1586
+ decompress=ALLELE_XML_DECOMPRESS)
1587
+ os.remove(path)
1588
+
1589
+ Allele = namedtuple(""Allele"", [
1590
+ ""name"",
1591
+ ""mhc_class"",
1592
+ ""locus"",
1593
+ ""organism"",
1594
+ ""synonyms""
1595
+ ])
1596
+
1597
+ @memoize
1598
+ def load_alleles():
1599
+ """"""Parses the IEDB MhcAlleleName XML file and returns a list of Allele
1600
+ namedtuple objects containing information about that each allele's HLA
1601
+ class and source organism.
1602
+ """"""
1603
+ result = []
1604
+ path = local_path()
1605
+ etree = xml.etree.ElementTree.parse(path)
1606
+ for allele in etree.iterfind(""MhcAlleleName""):
1607
+ name_element = allele.find(""DisplayedRestriction"")
1608
+ mhc_class_element = allele.find(""Class"")
1609
+ # need at least a name and an HLA class
1610
+ if name_element is None or mhc_class_element is None:
1611
+ continue
1612
+ name = name_element.text
1613
+
1614
+ synonyms = set([])
1615
+ for synonym_element in allele.iterfind(""Synonyms""):
1616
+ for synonym in synonym_element.text.split("",""):
1617
+ synonyms.add(synonym.strip())
1618
+ mhc_class = mhc_class_element.text
1619
+ organism_element = allele.find(""Organsim"")
1620
+ if organism_element is None:
1621
+ organism = None
1622
+ else:
1623
+ organism = organism_element.text
1624
+
1625
+ locus_element = allele.find(""Locus"")
1626
+
1627
+ if locus_element is None:
1628
+ locus = None
1629
+ else:
1630
+ locus = locus_element.text
1631
+
1632
+ allele_object = Allele(
1633
+ name=name,
1634
+ mhc_class=mhc_class,
1635
+ locus=locus,
1636
+ organism=organism,
1637
+ synonyms=synonyms)
1638
+ result.append(allele_object)
1639
+ return result
1640
+
1641
+ @memoize
1642
+ def load_alleles_dict():
1643
+ """"""Create a dictionary mapping each unique allele name to a namedtuple
1644
+ containing information about that alleles class, locus, species, &c.
1645
+ """"""
1646
+ alleles = load_alleles()
1647
+ result = {}
1648
+ for allele in alleles:
1649
+ for name in {allele.name}.union(allele.synonyms):
1650
+ result[name] = allele
1651
+ return result
1652
+ ","Python"
1653
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/common.py",".py","665","20","# Licensed under the Apache License, Version 2.0 (the ""License"");
1654
+ # you may not use this file except in compliance with the License.
1655
+ # You may obtain a copy of the License at
1656
+ #
1657
+ # http://www.apache.org/licenses/LICENSE-2.0
1658
+ #
1659
+ # Unless required by applicable law or agreed to in writing, software
1660
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1661
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1662
+ # See the License for the specific language governing permissions and
1663
+ # limitations under the License.
1664
+
1665
+ from __future__ import annotations
1666
+
1667
+ import datacache
1668
+
1669
+ cache = datacache.Cache(""pepdata"")
1670
+
1671
+ bad_amino_acids = 'U|X|J|B|Z'
1672
+ ","Python"
1673
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/__init__.py",".py","103","11","from . import (
1674
+ alleles,
1675
+ mhc,
1676
+ tcell
1677
+ )
1678
+
1679
+ __all__ = [
1680
+ ""alleles"",
1681
+ ""mhc"",
1682
+ ""tcell"",
1683
+ ]","Python"
1684
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/memoize.py",".py","1534","50","# Licensed under the Apache License, Version 2.0 (the ""License"");
1685
+ # you may not use this file except in compliance with the License.
1686
+ # You may obtain a copy of the License at
1687
+ #
1688
+ # http://www.apache.org/licenses/LICENSE-2.0
1689
+ #
1690
+ # Unless required by applicable law or agreed to in writing, software
1691
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1692
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1693
+ # See the License for the specific language governing permissions and
1694
+ # limitations under the License.
1695
+
1696
+ from __future__ import print_function, division, absolute_import
1697
+
1698
+ from functools import wraps
1699
+
1700
+ def _prepare_memoization_key(args, kwargs):
1701
+ """"""
1702
+ Make a tuple of arguments which can be used as a key
1703
+ for a memoized function's lookup_table. If some object can't be hashed
1704
+ then used its __repr__ instead.
1705
+ """"""
1706
+ key_list = []
1707
+ for arg in args:
1708
+ try:
1709
+ hash(arg)
1710
+ key_list.append(arg)
1711
+ except:
1712
+ key_list.append(repr(arg))
1713
+ for (k, v) in kwargs.items():
1714
+ try:
1715
+ hash(k)
1716
+ hash(v)
1717
+ key_list.append((k, v))
1718
+ except:
1719
+ key_list.append((repr(k), repr(v)))
1720
+ return tuple(key_list)
1721
+
1722
+ def memoize(fn):
1723
+ lookup_table = {}
1724
+
1725
+ @wraps(fn)
1726
+ def wrapped_fn(*args, **kwargs):
1727
+ key = _prepare_memoization_key(args, kwargs)
1728
+ if key not in lookup_table:
1729
+ lookup_table[key] = fn(*args, **kwargs)
1730
+ return lookup_table[key]
1731
+
1732
+ return wrapped_fn
1733
+ ","Python"
1734
+ "Hydrophilic","openvax/pepdata","pepdata/iedb/tcell.py",".py","6303","202","# Licensed under the Apache License, Version 2.0 (the ""License"");
1735
+ # you may not use this file except in compliance with the License.
1736
+ # You may obtain a copy of the License at
1737
+ #
1738
+ # http://www.apache.org/licenses/LICENSE-2.0
1739
+ #
1740
+ # Unless required by applicable law or agreed to in writing, software
1741
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1742
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1743
+ # See the License for the specific language governing permissions and
1744
+ # limitations under the License.
1745
+
1746
+
1747
+ from __future__ import print_function, division, absolute_import
1748
+ import logging
1749
+ import os
1750
+
1751
+ import numpy as np
1752
+ import pandas as pd
1753
+
1754
+
1755
+ from .alleles import load_alleles_dict
1756
+ from .memoize import memoize
1757
+ from .common import bad_amino_acids, cache
1758
+ from .columns import (
1759
+ get_assay_method,
1760
+ get_assay_num_tested,
1761
+ get_assay_response_measured,
1762
+ get_assay_units,
1763
+ get_host_name,
1764
+ get_mhc_allele,
1765
+ get_mhc_assay,
1766
+ get_mhc_class,
1767
+ get_epitope_source_organism,
1768
+ get_epitope_type,
1769
+ get_epitope_name,
1770
+
1771
+ )
1772
+
1773
+ TCELL_COMPACT_FILENAME = ""tcell_full.csv""
1774
+ TCELL_COMPACT_URL = ""http://www.iedb.org/downloader.php?file_name=doc/tcell_full_v3.zip""
1775
+ TCELL_COMPACT_DECOMPRESS = True
1776
+
1777
+ def download(force=False):
1778
+ return cache.fetch(
1779
+ filename=TCELL_COMPACT_FILENAME,
1780
+ url=TCELL_COMPACT_URL,
1781
+ decompress=TCELL_COMPACT_DECOMPRESS,
1782
+ force=force)
1783
+
1784
+ def local_path(auto_download=True):
1785
+ path = cache.local_path(
1786
+ filename=TCELL_COMPACT_FILENAME,
1787
+ url=TCELL_COMPACT_URL,
1788
+ decompress=TCELL_COMPACT_DECOMPRESS)
1789
+ if not os.path.exists(path):
1790
+ if auto_download:
1791
+ return download()
1792
+ raise ValueError(
1793
+ (""Local file %s does not exist, call""
1794
+ "" pepdata.iedb.tcell.download()"") % path)
1795
+ return path
1796
+
1797
+ def delete():
1798
+ os.remove(local_path())
1799
+
1800
+ @memoize
1801
+ def load_dataframe(
1802
+ mhc_class : str | None = None, # 1, 2, or None for neither
1803
+ mhc_pattern : str | None = None,
1804
+ exclude_mhc : str | None = None,
1805
+ human_only : bool =False,
1806
+ peptide_length : int | None = None,
1807
+ assay_method : str | None = None,
1808
+ only_standard_amino_acids : bool = True,
1809
+ reduced_alphabet : dict | None = None, # 20 letter AA strings -> simpler alphabet
1810
+ nrows : int | None = None):
1811
+ """"""
1812
+ Load IEDB T-cell data without aggregating multiple entries for same epitope
1813
+
1814
+ Parameters
1815
+ ----------
1816
+ mhc_class: {None, 1, 2}
1817
+ Restrict to MHC Class I or Class II (or None for neither)
1818
+
1819
+ mhc_pattern: regex pattern, optional
1820
+ Restrict results to specific MHC used in assay
1821
+
1822
+ exclude_mhc: regex pattern, optional
1823
+ Exclude certain MHC allele patterns
1824
+
1825
+ human_only: bool
1826
+ Restrict to human samples (default False)
1827
+
1828
+ peptide_length: int, optional
1829
+ Restrict epitopes to amino acid strings of given length
1830
+
1831
+ assay_method string, optional
1832
+ Only collect results with assay methods containing the given string
1833
+
1834
+ only_standard_amino_acids : bool, optional
1835
+ Drop sequences which use non-standard amino acids, anything outside
1836
+ the core 20, such as X or U (default = True)
1837
+
1838
+ reduced_alphabet: dictionary, optional
1839
+ Remap amino acid letters to some other alphabet
1840
+
1841
+ nrows: int, optional
1842
+ Don't load the full IEDB dataset but instead read only the first nrows
1843
+ """"""
1844
+ path = local_path()
1845
+ df = pd.read_csv(
1846
+ path,
1847
+ header=[0, 1],
1848
+ skipinitialspace=True,
1849
+ nrows=nrows,
1850
+ low_memory=False,
1851
+ on_bad_lines='warn',
1852
+ encoding=""latin-1"")
1853
+
1854
+ mhc = get_mhc_allele(df)
1855
+ mhc_class = get_mhc_class(df)
1856
+ epitopes = get_epitope_name(df)
1857
+ organism = get_host_name(df)
1858
+ assay_method = get_assay_method(df)
1859
+
1860
+
1861
+ # Sometimes the IEDB seems to put in an extra comma in the
1862
+ # header line, which creates an unnamed column of NaNs.
1863
+ # To deal with this, drop any columns which are all NaN
1864
+ df = df.dropna(axis=1, how=""all"")
1865
+
1866
+ n = len(df)
1867
+
1868
+ null_epitope_seq = epitopes.isnull()
1869
+ n_null = null_epitope_seq.sum()
1870
+
1871
+ if n_null > 0:
1872
+ logging.info(""Dropping %d null sequences"", n_null)
1873
+
1874
+ mask = ~null_epitope_seq
1875
+
1876
+ if only_standard_amino_acids:
1877
+ # if have rare or unknown amino acids, drop the sequence
1878
+ bad_epitope_seq = \
1879
+ epitopes.str.contains(bad_amino_acids, na=False).astype(""bool"")
1880
+ n_bad = bad_epitope_seq.sum()
1881
+ if n_bad > 0:
1882
+ logging.info(""Dropping %d bad sequences"", n_bad)
1883
+
1884
+ mask &= ~bad_epitope_seq
1885
+
1886
+ if human_only:
1887
+ mask &= organism.str.startswith('Homo sapiens', na=False).astype('bool')
1888
+
1889
+
1890
+ if mhc_class is not None:
1891
+ # since MHC classes can be specified as either strings (""I"") or integers
1892
+ # standard them to be strings
1893
+ if mhc_class == 1:
1894
+ mhc_class = ""I""
1895
+ elif mhc_class == 2:
1896
+ mhc_class = ""II""
1897
+ if mhc_class not in {""I"", ""II""}:
1898
+ raise ValueError(""Invalid MHC class: %s"" % mhc_class)
1899
+ allele_dict = load_alleles_dict()
1900
+ mhc_class_mask = [False] * len(df)
1901
+ for i, allele_name in enumerate(mhc):
1902
+ allele_object = allele_dict.get(allele_name)
1903
+ if allele_object and allele_object.mhc_class == mhc_class:
1904
+ mhc_class_mask[i] = True
1905
+ mask &= np.array(mhc_class_mask)
1906
+
1907
+ # Match known alleles such as ""HLA-A*02:01"",
1908
+ # broader groupings such as ""HLA-A2""
1909
+ # and unknown alleles of the MHC-1 listed either as
1910
+ # ""HLA-Class I,allele undetermined""
1911
+ # or
1912
+ # ""Class I,allele undetermined""
1913
+ ]
1914
+
1915
+ if hla:
1916
+ mask &= df[mhc_allele_column_key].str.contains(hla, na=False)
1917
+
1918
+ if exclude_hla:
1919
+ mask &= ~(df[mhc_allele_column_key].str.contains(exclude_hla, na=False))
1920
+
1921
+ if assay_group:
1922
+ mask &= df[assay_group_column_key].str.contains(assay_group)
1923
+
1924
+ if assay_method:
1925
+ mask &= df[assay_method_column_key].str.contains(assay_method)
1926
+
1927
+ if peptide_length:
1928
+ assert peptide_length > 0
1929
+ mask &= df[epitope_column_key].str.len() == peptide_length
1930
+
1931
+ df = df[mask]
1932
+
1933
+ logging.info(""Returning %d / %d entries after filtering"", len(df), n)
1934
+ return df
1935
+ ","Python"
1936
+ "Hydrophilic","openvax/pepdata","tests/test_iedb_tcell.py",".py","1918","50","# Licensed under the Apache License, Version 2.0 (the ""License"");
1937
+ # you may not use this file except in compliance with the License.
1938
+ # You may obtain a copy of the License at
1939
+ #
1940
+ # http://www.apache.org/licenses/LICENSE-2.0
1941
+ #
1942
+ # Unless required by applicable law or agreed to in writing, software
1943
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
1944
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1945
+ # See the License for the specific language governing permissions and
1946
+ # limitations under the License.
1947
+
1948
+ from pepdata import iedb
1949
+
1950
+ def test_tcell_hla_restrict_a24():
1951
+ """"""
1952
+ IEDB T-cell: Test that HLA restriction actually decreases
1953
+ number of results and that regular expression patterns
1954
+ are being used correctly
1955
+ """"""
1956
+ df_all = iedb.tcell.load_dataframe(nrows=1000)
1957
+ df_a24_1 = iedb.tcell.load_dataframe(hla='HLA-A24', nrows=1000)
1958
+ df_a24_2 = iedb.tcell.load_dataframe(hla=r'HLA-A\*24', nrows=1000)
1959
+ df_a24_combined = \
1960
+ iedb.tcell.load_dataframe(hla=r'HLA-A24|HLA-A\*24', nrows=1000)
1961
+ assert len(df_a24_1) < len(df_all)
1962
+ assert len(df_a24_2) < len(df_all)
1963
+ assert len(df_a24_combined) <= \
1964
+ len(df_a24_1) + len(df_a24_2), \
1965
+ ""Expected %d <= %d + %d"" % \
1966
+ (len(df_a24_combined), len(df_a24_1), len(df_a24_2))
1967
+
1968
+ def test_tcell_hla_exclude_a0201():
1969
+ """"""
1970
+ Test that excluding HLA allele A*02:01
1971
+ actually returns a DataFrame not containing
1972
+ that allele
1973
+ """"""
1974
+ df_all = iedb.tcell.load_dataframe(nrows=1000)
1975
+ assert (df_all['MHC']['Allele Name'] == ""HLA-A*02:01"").any()
1976
+
1977
+ df_exclude = iedb.tcell.load_dataframe(
1978
+ nrows=1000,
1979
+ exclude_hla=""HLA-A\*02:01"")
1980
+
1981
+ n_A0201_entries = (df_exclude['MHC']['Allele Name'] == ""HLA-A*02:01"").sum()
1982
+ assert n_A0201_entries == 0, \
1983
+ (""Not supposed to contain HLA-A*02:01, ""
1984
+ "" but found %d rows of that allele"") % n_A0201_entries
1985
+ ","Python"
1986
+ "Hydrophilic","openvax/pepdata","tests/test_blosum.py",".py","242","17","from pepdata.blosum import (
1987
+ blosum30_dict,
1988
+ blosum30_matrix,
1989
+ blosum50_dict,
1990
+ blosum50_matrix,
1991
+ blosum62_dict,
1992
+ blosum62_matrix
1993
+ )
1994
+
1995
+ def test_blosum30():
1996
+ pass
1997
+
1998
+ def test_blosum50():
1999
+ pass
2000
+
2001
+ def test_blosum62():
2002
+ pass","Python"
2003
+ "Hydrophilic","openvax/pepdata","tests/test_pmbec.py",".py","92","8","from pepdata.pmbec import (
2004
+ pmbec_dict,
2005
+ pmbec_matrix,
2006
+ )
2007
+
2008
+ def test_pmbec():
2009
+ pass
2010
+ ","Python"
2011
+ "Hydrophilic","openvax/pepdata","tests/test_iedb_alleles.py",".py","1422","44","# Licensed under the Apache License, Version 2.0 (the ""License"");
2012
+ # you may not use this file except in compliance with the License.
2013
+ # You may obtain a copy of the License at
2014
+ #
2015
+ # http://www.apache.org/licenses/LICENSE-2.0
2016
+ #
2017
+ # Unless required by applicable law or agreed to in writing, software
2018
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
2019
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2020
+ # See the License for the specific language governing permissions and
2021
+ # limitations under the License.
2022
+
2023
+
2024
+ from __future__ import print_function, division, absolute_import
2025
+
2026
+ from nose.tools import eq_
2027
+
2028
+ from pepdata import iedb
2029
+
2030
+ def test_iedb_human_class1_allele():
2031
+ allele_dict = iedb.alleles.load_alleles_dict()
2032
+ allele = allele_dict[""HLA-C*07:02""]
2033
+ eq_(allele.mhc_class, ""I"")
2034
+ eq_(allele.locus, ""C"")
2035
+
2036
+ def test_iedb_human_class2_allele():
2037
+ allele_dict = iedb.alleles.load_alleles_dict()
2038
+ allele = allele_dict[""HLA-DRA*01:01/DRB1*04:04""]
2039
+ eq_(allele.mhc_class, ""II"")
2040
+ eq_(allele.locus, ""DR"")
2041
+
2042
+
2043
+ def test_iedb_mouse_class1_allele():
2044
+ allele_dict = iedb.alleles.load_alleles_dict()
2045
+ allele = allele_dict[""H-2-Ds""]
2046
+ eq_(allele.mhc_class, ""I"")
2047
+ eq_(allele.locus, ""D"")
2048
+
2049
+ def test_iedb_mouse_class2_allele():
2050
+ allele_dict = iedb.alleles.load_alleles_dict()
2051
+ allele = allele_dict[""H-2-IAq""]
2052
+ eq_(allele.mhc_class, ""II"")
2053
+ eq_(allele.locus, ""IA"")
2054
+ ","Python"
2055
+ "Hydrophilic","openvax/pepdata","tests/test_ngram.py",".py","2411","63","# Copyright (c) 2014. Mount Sinai School of Medicine
2056
+ #
2057
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
2058
+ # you may not use this file except in compliance with the License.
2059
+ # You may obtain a copy of the License at
2060
+ #
2061
+ # http://www.apache.org/licenses/LICENSE-2.0
2062
+ #
2063
+ # Unless required by applicable law or agreed to in writing, software
2064
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
2065
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2066
+ # See the License for the specific language governing permissions and
2067
+ # limitations under the License.
2068
+
2069
+ from __future__ import print_function, division, absolute_import
2070
+ from six.moves import cPickle
2071
+
2072
+ from pepdata import PeptideVectorizer
2073
+
2074
+ # isoforms of two different proteins a, b
2075
+
2076
+ a1 = (
2077
+ ""MSPHPTALLGLVLCLAQTIHTQEEDLPRPSISAEPGTVIPLGSHVTFVCRGPVGVQTFRLERESRSTYND""
2078
+ ""TEDVSQASPSESEARFRIDSVSEGNAGPYRCIYYKPPKWSEQSDYLELLVKETSGGPDSPDTEPGSSAGPT""
2079
+ ""QRPSDNSHNEHAPASQGLKAEHLYILIGVSVVFLFCLLLLVLFCLHRQNQIKQGPPRSKDEEQKPQQRPDL""
2080
+ ""AVDVLERTADKATVNGLPEKDRETDTSALAAGSSQEVTYAQLDHWALTQRTARAVSPQSTKPMAESITYAA""
2081
+ ""VARH""
2082
+ )
2083
+
2084
+ a2 = (
2085
+ ""MSLMVVSMACVGFFLLQGAWPHEGVHRKPSLLAHPGPLVKSEETVILQCWSDVRFEHFLLHREGKYKDTLH""
2086
+ ""LIGEHHDGVSKANFSIGPMMQDLAGTYRCYGSVTHSPYQLSAPSDPLDIVITGLYEKPSLSAQPGPTVLAG""
2087
+ ""ESVTLSCSSRSSYDMYHLSREGEAHERRFSAGPKVNGTFQADFPLGPATHGGTYRCFGSFRDSPYEWSNSS""
2088
+ ""DPLLVSVTGNPSNSWPSPTEPSSKTGNPRHLHVLIGTSVVKIPFTILLFFLLHRWCSNKKNAAVMDQEPAG""
2089
+ ""NRTVNSEDSDEQDHQEVSYA""
2090
+ )
2091
+
2092
+ a3 = (
2093
+ ""MSLMVVSMACVGFFLLEGPWPHVGGQDKPFLSAWPGTVVSEGQHVTLQCRSRLGFNEFSLSKEDGMPVPEL""
2094
+ ""YNRIFRNSFLMGPVTPAHAGTYRCCSSHPHSPTGWSAPSNPVVIMVTGVHRKPSLLAHPGPLVKSEETVIL""
2095
+ ""QCWSDVRFEHFLLHREGKYKDTLHLIGEHHDGVSKANFSIGPMMQDLAGTYRCYGSVTHSPYQLSAPSDPL""
2096
+ ""DIVITGLYEKPSLSAQPGPTVLAGESVTLSCSSRSSYDMYHLSREGEAHERRFSAGPKVNGTFQADFPLGP""
2097
+ ""ATHGGTYRCFGSFRDSPYEWSNSSDPLLVSVTAFLSVKSSGHKYIY""
2098
+ )
2099
+
2100
+ A = [a1, a2, a3]
2101
+
2102
+ b1 = (
2103
+ ""MPKGRAGSLPTTSIGWRFQLWFLGLTCPERHLARRLKNNSFYPFVQQEPNVFVLEYYLDTLWKGMLLFII""
2104
+ ""SVVLVSFSSLREVQKQETWVFLVYGVGVGLWLVISSLPRRRLVLNHTRGVYHFSIQGRTVCQGPLHLVYV""
2105
+ ""RLALSSDAHGRCFFHLVLGGHRLEPLVLVQLSEHYEQMEYLGRYIARKLNINYFDYLATSYRHVVRHWPP""
2106
+ ""PGAGTVMGKSPMGHKPSSSQSSLEV""
2107
+ )
2108
+
2109
+ b2 = (
2110
+ ""MPKGRAGSLPTTSIGWRFQLWFLGLTCPERHLARRLKNNSFYPFVQQEPNVFVLEYYLDTLWKGMLLFII""
2111
+ ""SVVLVSFSSLREVQKQETWVFLVYGVGVGLWLVISSLPRRRLVLNHTRGVYHFSIQGRTVCQGPLHLVYV""
2112
+ ""RLALSSDAHGRCFFHLVLGGHRLEPLVLVQLSEHYEQMEYLGRYIARKLNINYFDYLATSYRHVVRHWPPP""
2113
+ ""GAGTVMGKSPMGHKPSSSQSSLEV""
2114
+ )
2115
+
2116
+ B = [b1, b2]
2117
+ ","Python"
2118
+ "Hydrophilic","openvax/pepdata","tests/test_iedb_mhc.py",".py","1373","33","# Copyright (c) 2014. Mount Sinai School of Medicine
2119
+ #
2120
+ # Licensed under the Apache License, Version 2.0 (the ""License"");
2121
+ # you may not use this file except in compliance with the License.
2122
+ # You may obtain a copy of the License at
2123
+ #
2124
+ # http://www.apache.org/licenses/LICENSE-2.0
2125
+ #
2126
+ # Unless required by applicable law or agreed to in writing, software
2127
+ # distributed under the License is distributed on an ""AS IS"" BASIS,
2128
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2129
+ # See the License for the specific language governing permissions and
2130
+ # limitations under the License.
2131
+
2132
+ from __future__ import print_function, division, absolute_import
2133
+
2134
+ from pepdata import iedb
2135
+
2136
+ def test_mhc_hla_a2():
2137
+ """"""
2138
+ IEDB MHC: Test that HLA restriction actually decreases number of results and
2139
+ that regular expression patterns are being used correctly
2140
+ """"""
2141
+ df_all = iedb.mhc.load_dataframe(nrows=1000)
2142
+ df_a2_1 = iedb.mhc.load_dataframe(hla='HLA-A2', nrows=1000)
2143
+ df_a2_2 = iedb.mhc.load_dataframe(hla=r'HLA-A\*02', nrows=1000)
2144
+ df_a2_combined = iedb.mhc.load_dataframe(hla=r'HLA-A2|HLA-A\*02', nrows=1000)
2145
+ assert len(df_a2_1) < len(df_all)
2146
+ assert len(df_a2_2) < len(df_all)
2147
+ assert len(df_a2_combined) <= len(df_a2_1) + len(df_a2_2), \
2148
+ ""Expected %d <= %d + %d"" % \
2149
+ (len(df_a2_combined), len(df_a2_1), len(df_a2_2))
2150
+ ","Python"
2151
+ "Hydrophilic","openvax/pepdata","tests/test_amino_acids.py",".py","918","27","from nose.tools import eq_
2152
+ from pepdata.amino_acid_alphabet import (
2153
+ canonical_amino_acids,
2154
+ canonical_amino_acid_letters,
2155
+ extended_amino_acids,
2156
+ extended_amino_acid_letters,
2157
+ )
2158
+
2159
+ def test_canonical_amino_acids():
2160
+ assert len(canonical_amino_acids) == 20
2161
+
2162
+ def test_canonical_amino_acids_letters():
2163
+ assert len(canonical_amino_acid_letters) == 20
2164
+ assert ""X"" not in canonical_amino_acid_letters
2165
+ expected_letters = [aa.letter for aa in canonical_amino_acids]
2166
+ eq_(expected_letters, canonical_amino_acid_letters)
2167
+
2168
+ def test_extended_amino_acids():
2169
+ assert len(extended_amino_acids) > 20
2170
+
2171
+ def test_extended_amino_acids_letters():
2172
+ assert len(extended_amino_acid_letters) > 20
2173
+ assert ""X"" in extended_amino_acid_letters
2174
+ assert ""J"" in extended_amino_acid_letters
2175
+ expected_letters = [aa.letter for aa in extended_amino_acids]
2176
+ eq_(expected_letters, extended_amino_acid_letters)
2177
+ ","Python"