Skip to content

Commit

Permalink
Use allele.organism instead of str for allele conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
skrakau committed Apr 22, 2020
1 parent bc97853 commit aa71ae3
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Fred2/EpitopePrediction/ANN.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def _represent(self, allele):
:return: str
"""
if isinstance(allele, MouseAllele):
return "H-2-%s%s%s" % (allele.locus, allele.supertype.upper(), allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype.upper(), allele.subtype)
else:
return "HLA-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts FRED2s internal allele representation into the format required by mhcnuggets
def convert_alleles(self, alleles):
Expand Down Expand Up @@ -308,9 +308,9 @@ def _represent(self, allele):
:return: str
"""
if isinstance(allele, MouseAllele):
return "H-2-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)
else:
return "HLA-%s%s:%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s:%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts the internal mhcnuggets-class-1 HLA representation back into a FRED2 representation
def revert_allele_repr(self, name):
Expand Down Expand Up @@ -408,12 +408,12 @@ def _represent(self, allele):
"""
if isinstance(allele, MouseAllele):
# expects H-2-XXx
return "H-2-%s%s%s" % (allele.locus, allele.supertype.upper(), allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype.upper(), allele.subtype)
elif isinstance(allele, CombinedAllele):
return "HLA-%s%s%s-%s%s%s" % (allele.alpha_locus, allele.alpha_supertype, allele.alpha_subtype,
return "%s-%s%s%s-%s%s%s" % (allele.organism, allele.alpha_locus, allele.alpha_supertype, allele.alpha_subtype,
allele.beta_locus, allele.beta_supertype, allele.beta_subtype)
else:
return "HLA-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts FRED2s internal allele representation into the format required by mhcnuggets
def convert_alleles(self, alleles):
Expand Down Expand Up @@ -599,12 +599,12 @@ def _represent(self, allele):
"""
if isinstance(allele, MouseAllele):
# expects H-2-XXx
return "H-2-%s%s%s" % (allele.locus, allele.supertype.upper(), allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype.upper(), allele.subtype)
elif isinstance(allele, CombinedAllele):
return "HLA-%s%s:%s-%s%s:%s" % (allele.alpha_locus, allele.alpha_supertype, allele.alpha_subtype,
return "%s-%s%s:%s-%s%s:%s" % (allele.organism, allele.alpha_locus, allele.alpha_supertype, allele.alpha_subtype,
allele.beta_locus, allele.beta_supertype, allele.beta_subtype)
else:
return "HLA-%s%s:%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s:%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts the internal mhcnuggets-class-2 representation back into a FRED2 representation
def revert_allele_repr(self, name):
Expand Down Expand Up @@ -684,9 +684,9 @@ def _represent(self, allele):
:return: str
"""
if isinstance(allele, MouseAllele):
return "H-2-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)
else:
return "HLA-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts FRED2s internal allele representation into the format required by MHCFlurry
def convert_alleles(self, alleles):
Expand Down Expand Up @@ -825,9 +825,9 @@ def _represent(self, allele):
:return: str
"""
if isinstance(allele, MouseAllele):
return "H-2-%s%s%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s%s%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)
else:
return "HLA-%s*%s:%s" % (allele.locus, allele.supertype, allele.subtype)
return "%s-%s*%s:%s" % (allele.organism, allele.locus, allele.supertype, allele.subtype)

# Converts the internal MHCFlurry representation back into a FRED2 representation
def revert_allele_repr(self, name):
Expand Down

0 comments on commit aa71ae3

Please sign in to comment.