Skip to content

Commit

Permalink
Merge pull request #239 from FRED-2/develop
Browse files Browse the repository at this point in the history
Version 2.0.6
  • Loading branch information
christopher-mohr authored Feb 10, 2020
2 parents 3340417 + f70712f commit 66349b1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Fred2/Data/pssms/pcm/mat/pcm_6.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pcm_6 = {0: {'A': 0.4731237565819792, 'C': -0.5025268209512956, 'E': -0.21691300156357377, 'D': -0.5025268209512956, 'G': -2.2537949288246137, 'F': -0.3495574761698686, 'I': 0.004987541511038968, 'H': 1.1647120903726331, 'K': -0.3495574761698686, 'M': 0.004987541511038968, 'L': 0.09984533496971612, 'N': 0.18647956694261839, 'Q': -0.6831968497067774, 'P': -0.3495574761698686, 'S': 0.2662030407746567, 'R': 0.2662030407746567, 'T': -0.21691300156357377, 'W': -0.903868211875598, 'V': 0.004987541511038968, 'Y': 0.2662030407746567}, 1: {'A': 0.4731237565819792, 'C': -0.5025268209512956, 'E': -0.0998203352822109, 'D': -0.0998203352822109, 'G': -5.298317366548036, 'F': -0.5025268209512956, 'I': -0.0998203352822109, 'H': 0.7907275088988094, 'K': -0.21691300156357377, 'M': -0.21691300156357377, 'L': 0.2662030407746567, 'N': 0.7907275088988094, 'Q': -0.903868211875598, 'P': -0.5025268209512956, 'S': 0.2662030407746567, 'R': 0.2662030407746567, 'T': -0.3495574761698686, 'W': -0.903868211875598, 'V': -0.3495574761698686, 'Y': 0.5335651107354802}, 2: {'A': 0.5335651107354802, 'C': 0.004987541511038968, 'E': 0.18647956694261839, 'D': -0.6831968497067774, 'G': -2.2537949288246137, 'F': 0.40879289820083897, 'I': 0.09984533496971612, 'H': 1.1002775679871708, 'K': -0.6831968497067774, 'M': -1.1874435023747254, 'L': -0.21691300156357377, 'N': 0.3400373027857091, 'Q': -0.6831968497067774, 'P': -0.0998203352822109, 'S': -1.1874435023747254, 'R': 0.4731237565819792, 'T': 0.004987541511038968, 'W': -2.2537949288246137, 'V': -0.0998203352822109, 'Y': 0.40879289820083897}, 3: {'A': 0.7443154671343447, 'C': 0.09984533496971612, 'E': -0.903868211875598, 'D': 0.3400373027857091, 'G': -5.298317366548036, 'F': -0.21691300156357377, 'I': 0.2662030407746567, 'H': 0.5335651107354802, 'K': -0.5025268209512956, 'M': -0.3495574761698686, 'L': 0.6444820085786643, 'N': -0.3495574761698686, 'Q': -0.6831968497067774, 'P': 0.004987541511038968, 'S': -0.903868211875598, 'R': -0.3495574761698686, 'T': -0.6831968497067774, 'W': -0.0998203352822109, 'V': 0.3400373027857091, 'Y': 0.5905605917848442}, 4: {'A': 0.8775499035577246, 'C': 0.004987541511038968, 'E': 0.18647956694261839, 'D': -0.21691300156357377, 'G': -5.298317366548036, 'F': -0.21691300156357377, 'I': -0.0998203352822109, 'H': 1.0314035389746596, 'K': -0.6831968497067774, 'M': -1.584745299843729, 'L': 0.004987541511038968, 'N': 0.40879289820083897, 'Q': -0.5025268209512956, 'P': -2.2537949288246137, 'S': 0.2662030407746567, 'R': 0.4731237565819792, 'T': 0.004987541511038968, 'W': -0.6831968497067774, 'V': 0.18647956694261839, 'Y': -0.6831968497067774}, 5: {'A': 0.3400373027857091, 'C': -0.21691300156357377, 'E': 0.5905605917848442, 'D': 0.3400373027857091, 'G': -5.298317366548036, 'F': 0.18647956694261839, 'I': 0.004987541511038968, 'H': 0.9182887345368281, 'K': -0.21691300156357377, 'M': 0.004987541511038968, 'L': 0.40879289820083897, 'N': -0.903868211875598, 'Q': -1.584745299843729, 'P': -0.21691300156357377, 'S': -0.3495574761698686, 'R': -0.21691300156357377, 'T': 0.18647956694261839, 'W': -0.5025268209512956, 'V': -0.21691300156357377, 'Y': 0.004987541511038968}}
pcm_6 = {0: {'A': -0.07, 'R': -0.31, 'N': -0.24, 'D': -0.34, 'C': 0.16, 'Q': -0.17, 'E': -0.03, 'G': 0.32, 'H': 0.12, 'I': 0.05, 'L': -0.2, 'K': -0.23, 'M': 0.22, 'F': 0.13, 'P': 0.22, 'S': 0.04, 'T': -0.12, 'W': 0.31, 'Y': 0.27, 'V': -0.14}, 1: {'A': -0.18, 'R': -0.31, 'N': -0.12, 'D': -0.23, 'C': -5.49, 'Q': -0.08, 'E': -0.03, 'G': -0.09, 'H': 0.12, 'I': -0.04, 'L': 0.13, 'K': 0.42, 'M': 0.22, 'F': 0.01, 'P': -0.02, 'S': -0.16, 'T': -0.23, 'W': 0.31, 'Y': 0.05, 'V': 0.18}, 2: {'A': -0.01, 'R': 0.38, 'N': 0.24, 'D': -0.81, 'C': 0.16, 'Q': 0.43, 'E': 0.04, 'G': 0.22, 'H': -0.16, 'I': -0.73, 'L': -0.42, 'K': 0.04, 'M': 0.22, 'F': 0.23, 'P': -1.29, 'S': 0.2, 'T': 0.28, 'W': -1.29, 'Y': 0.16, 'V': 0.13}, 3: {'A': 0.22, 'R': 0.29, 'N': -0.71, 'D': 0.41, 'C': -5.49, 'Q': 0.07, 'E': 0.16, 'G': -0.29, 'H': -0.01, 'I': -0.27, 'L': 0.38, 'K': -0.85, 'M': 0.37, 'F': 0.33, 'P': -1.29, 'S': -0.71, 'T': -0.48, 'W': 1.0, 'Y': 0.8, 'V': 0.18}, 4: {'A': 0.3, 'R': 0.2, 'N': 0.16, 'D': -0.34, 'C': -5.49, 'Q': -0.08, 'E': -0.27, 'G': 0.22, 'H': -0.16, 'I': -1.64, 'L': -0.27, 'K': -0.02, 'M': 0.63, 'F': -0.96, 'P': 0.18, 'S': 0.34, 'T': 0.14, 'W': 0.31, 'Y': 0.53, 'V': -0.96}, 5: {'A': -0.18, 'R': -0.02, 'N': 0.57, 'D': 0.28, 'C': -5.49, 'Q': 0.14, 'E': -0.18, 'G': 0.08, 'H': 0.44, 'I': 0.05, 'L': 0.22, 'K': -1.4, 'M': -0.47, 'F': 0.41, 'P': -0.34, 'S': -0.4, 'T': 0.14, 'W': 0.64, 'Y': 0.16, 'V': -0.2}}
22 changes: 14 additions & 8 deletions Fred2/EpitopePrediction/ANN.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ def predict(self, peptides, alleles=None, binary=False, **kwargs):
# filter for supported alleles
alleles = filter(lambda a: a in self.supportedAlleles, alleles)

# fetch peptides as strings
peptides = [str(peptide) for peptide in peptides]
# keep input peptide objects for later use
peptide_objects = {}
for peptide in peptides:
peptide_objects[str(peptide)] = peptide

# write peptides temporarily, new line separated
tmp_input_file = tempfile.NamedTemporaryFile().name
with open(tmp_input_file, 'wb') as file:
for peptide in peptides:
for peptide in peptide_objects.keys():
file.write(peptide + "\n")

alleles = self.convert_alleles(alleles)
Expand All @@ -177,7 +179,8 @@ def predict(self, peptides, alleles=None, binary=False, **kwargs):
# assign binding affinities
for row in reader:
content = row[0].split(',')
peptide = content[0]
# get original peptide object
peptide = peptide_objects[content[0]]
binding_affinity = content[1]
if binary:
if binding_affinity <= 500:
Expand Down Expand Up @@ -294,15 +297,17 @@ def predict(self, peptides, alleles=None, binary=False, **kwargs):
# filter for supported alleles
alleles = filter(lambda a: a in self.supportedAlleles, alleles)

# fetch peptides as strings
peptides = [str(peptide) for peptide in peptides]
# keep input peptide objects for later
peptide_objects = {}
for peptide in peptides:
peptide_objects[str(peptide)] = peptide

alleles = self.convert_alleles(alleles)

# write peptides temporarily, new line separated
tmp_input_file = tempfile.NamedTemporaryFile().name
with open(tmp_input_file, 'wb') as file:
for peptide in peptides:
for peptide in peptide_objects.keys():
file.write(peptide + "\n")

result = {}
Expand All @@ -325,7 +330,8 @@ def predict(self, peptides, alleles=None, binary=False, **kwargs):

for row in reader:
content = row[0].split(',')
peptide = content[0]
# get original peptide object
peptide = peptide_objects[content[0]]
binding_affinity = content[1]
if binary:
if binding_affinity <= 500:
Expand Down
37 changes: 37 additions & 0 deletions Fred2/EpitopePrediction/External.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,43 @@ def parse_external_result(self, file):
return result



class NetMHCpan_4_0(NetMHCpan_3_0):
"""
Implements the NetMHC binding version 4.0
Supported MHC alleles currently only restricted to HLA alleles.
"""
__version = "4.0"
__command = "netMHCpan -p {peptides} -a {alleles} {options} -xls -xlsfile {out}"
@property
def version(self):
return self.__version

@property
def command(self):
return self.__command

def parse_external_result(self, file):
"""
Parses external results and returns the result

:param str file: The file path or the external prediction results
:return: A dictionary containing the prediction results
:rtype: dict
"""
result = defaultdict(defaultdict)
f = csv.reader(open(file, "r"), delimiter='\t')
alleles = list(filter(lambda x: x != "", f.next()))
f.next()
ic_pos = 5
for row in f:
pep_seq = row[1]
for i, a in enumerate(alleles):
result[a][pep_seq] = float(row[ic_pos + i * 5])
return result



class NetMHCstabpan_1_0(AExternalEpitopePrediction):
"""
Implements a wrapper to NetMHCstabpan 1.0
Expand Down
4 changes: 2 additions & 2 deletions Fred2/test/TestEpitopeAssembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_simple_assembly(self):
pred = CleavageSitePredictorFactory("PCM")
assembler = EpitopeAssembly(self.peptides, pred, solver="cbc", verbosity=0)
r = assembler.solve()
self.assertEqual(r, [Peptide("YLYDHLAPM"), Peptide("ALYDVVSTL"), Peptide("KLLPRLPGV")])
self.assertEqual(r, [Peptide("KLLPRLPGV"), Peptide("ALYDVVSTL"), Peptide("YLYDHLAPM")])



Expand Down Expand Up @@ -53,4 +53,4 @@ def test_pareto_front_assembly(self):
r = assembler.paretosolve()
print r

#print assembler.solve(eps=2.0)
#print assembler.solve(eps=2.0)
4 changes: 2 additions & 2 deletions Fred2/test/TestSpacerDesign.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_standart_functions(self):
sbws = EpitopeAssemblyWithSpacer(self.epis, cl_pred, epi_pred, self.alleles, solver="cbc")
sol = sbws.solve()
print sol
assert all(i == str(j) for i, j in zip(["GHRMAWDMM", "HH", "VYEADDVIL"], sol))
assert all(i == str(j) for i, j in zip(["GHRMAWDMM", "WWQW", "VYEADDVIL"], sol))

def test_unsupported_allele_length_combination(self):
"""
Expand All @@ -47,7 +47,7 @@ def test_unsupported_allele_length_combination(self):
sbws = EpitopeAssemblyWithSpacer(self.epis, cl_pred, epi_pred, alleles, solver="cbc")
sol = sbws.solve()
print sol
assert all(i == str(j) for i, j in zip(["GHRMAWDMM", "HH", "VYEADDVIL"], sol))
assert all(i == str(j) for i, j in zip(["GHRMAWDMM", "WWQW", "VYEADDVIL"], sol))

def test_unsupported_allele_length_combination_exception(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
name='Fred2',

# Version:
version='2.0.5',
version='2.0.6',

description='A Framework for Epitope Detection and Vaccine Design',
long_description=readme,
Expand Down

0 comments on commit 66349b1

Please sign in to comment.