Skip to content

Commit

Permalink
distance_bounds now floats
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Simkovic committed Jul 30, 2017
1 parent 2c6415b commit bdd14c7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
v0.8.3dev1
----------

- Distance definitions accept floating point values
- Bug fix in ``PconsParser`` class to accept negative ``raw_score`` values
- Bug fix in ``SequenceFile.neff`` which returned ``float`` instead of ``int``
- ``requirements.txt`` file re-added for easier dependency installation
Expand Down
12 changes: 6 additions & 6 deletions conkit/core/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, res1_seq, res2_seq, raw_score, distance_bound=(0, 8)):
The residue sequence number of residue 2
"""
self._distance_bound = [0, 8]
self._distance_bound = [0., 8.]
self._raw_score = 1.0
self._res1 = 'X'
self._res2 = 'X'
Expand Down Expand Up @@ -195,7 +195,7 @@ def lower_bound(self, value):
Parameters
----------
value : int
value : int, float
Raises
------
Expand All @@ -209,7 +209,7 @@ def lower_bound(self, value):
raise ValueError('Lower bound must be positive')
elif value >= self.upper_bound:
raise ValueError('Lower bound must be smaller than upper bound')
self._distance_bound[0] = value
self._distance_bound[0] = float(value)

@property
def upper_bound(self):
Expand All @@ -222,7 +222,7 @@ def upper_bound(self, value):
Parameters
----------
value : int
value : int, float
Raises
------
Expand All @@ -236,7 +236,7 @@ def upper_bound(self, value):
raise ValueError('Upper bound must be positive')
elif value <= self.lower_bound:
raise ValueError('Upper bound must be larger than lower bound')
self._distance_bound[1] = value
self._distance_bound[1] = float(value)

@property
def raw_score(self):
Expand All @@ -249,7 +249,7 @@ def raw_score(self, score):
Parameters
----------
score : float
score : int, float
"""
self._raw_score = float(score)
Expand Down
7 changes: 4 additions & 3 deletions conkit/io/casp.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def read(self, f_handle, f_id="casp"):
res2_chain, res2_seq = res2_split[1], res2_split[2]

contact = Contact(int(res1_seq), int(res2_seq), float(raw_score),
distance_bound=(int(lb), int(ub)))
distance_bound=(float(lb), float(ub)))
contact.res1_chain = res1_chain
contact.res2_chain = res2_chain
contact.res1_altseq = int(res1_seq)
Expand Down Expand Up @@ -221,9 +221,10 @@ def write(self, f_handle, hierarchy):
else:
res1_chain = contact.res1_chain
res2_chain = contact.res2_chain
lb = int(contact.lower_bound) if float(contact.lower_bound).is_integer() else contact.lower_bound
ub = int(contact.upper_bound) if float(contact.upper_bound).is_integer() else contact.upper_bound
s = s.format(res1_chain=res1_chain, res1_seq=contact.res1_seq, res2_chain=res2_chain,
res2_seq=contact.res2_seq, lb=contact.distance_bound[0], ub=contact.distance_bound[1],
raw_score=contact.raw_score)
res2_seq=contact.res2_seq, lb=lb, ub=ub, raw_score=contact.raw_score)
content += s + os.linesep
content += "ENDMDL" + os.linesep

Expand Down
6 changes: 4 additions & 2 deletions conkit/io/epcmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def read(self, f_handle, f_id="epcmap"):

elif line[0].isdigit():
_contact = Contact(int(line[0]), int(line[1]), float(line[4]),
distance_bound=(int(line[2]), int(line[3])))
distance_bound=(float(line[2]), float(line[3])))
_map.add(_contact)

hierarchy.method = 'Contact map predicted using EPC-Map'
Expand Down Expand Up @@ -108,8 +108,10 @@ def write(self, f_handle, hierarchy):
for contact_map in contact_file:
for contact in contact_map:
line = "{res1_seq} {res2_seq} {lb} {ub} {raw_score:.6f}"
lb = int(contact.lower_bound) if float(contact.lower_bound).is_integer() else contact.lower_bound
ub = int(contact.upper_bound) if float(contact.upper_bound).is_integer() else contact.upper_bound
line = line.format(res1_seq=contact.res1_seq, res2_seq=contact.res2_seq, raw_score=contact.raw_score,
lb=contact.distance_bound[0], ub=contact.distance_bound[1])
lb=lb, ub=ub)
content += line + os.linesep

f_handle.write(content)
2 changes: 1 addition & 1 deletion conkit/io/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _read(self, structure, f_id, distance_cutoff, atom_type):
atom1.resseq,
atom2.resseq,
round(1.0-(distance/100), 6),
distance_bound=(0, distance_cutoff)
distance_bound=(0., float(distance_cutoff))
)

contact.res1_altseq = atom1.resseq_alt
Expand Down
6 changes: 4 additions & 2 deletions conkit/io/psicov.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def read(self, f_handle, f_id="psicov"):

elif line[0].isdigit():
_contact = Contact(int(line[0]), int(line[1]), float(line[4]),
distance_bound=(int(line[2]), int(line[3])))
distance_bound=(float(line[2]), float(line[3])))
_map.add(_contact)

hierarchy.method = 'Contact map predicted using PSICOV'
Expand Down Expand Up @@ -109,8 +109,10 @@ def write(self, f_handle, hierarchy):
for contact_map in contact_file:
for contact in contact_map:
line = "{res1_seq} {res2_seq} {lb} {ub} {raw_score:.6f}"
lb = int(contact.lower_bound) if float(contact.lower_bound).is_integer() else contact.lower_bound
ub = int(contact.upper_bound) if float(contact.upper_bound).is_integer() else contact.upper_bound
line = line.format(res1_seq=contact.res1_seq, res2_seq=contact.res2_seq, raw_score=contact.raw_score,
lb=contact.distance_bound[0], ub=contact.distance_bound[1])
lb=lb, ub=ub)
content += line + os.linesep

f_handle.write(content)

0 comments on commit bdd14c7

Please sign in to comment.