Skip to content

Commit

Permalink
Some minor fixes suggested by QuantifiedCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
swails committed Jun 12, 2015
1 parent ae4b181 commit 47a85ef
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .checkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mdtraj/utils/external
mdtraj/utils/six
mdtraj/utils/unit
4 changes: 2 additions & 2 deletions mdtraj/core/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def _parse_topology(top):
topology : md.Topology
"""

try:
if isinstance(top, string_types):
ext = _get_extension(top)
except:
else:
ext = None # might not be a string

if isinstance(top, string_types) and (ext in ['.pdb', '.pdb.gz', '.h5','.lh5']):
Expand Down
2 changes: 1 addition & 1 deletion mdtraj/formats/hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def tell(self):
return int(self._frame_index)

def _validate(self):
raise NotImplemented
raise NotImplementedError()

# check that all of the shapes are consistent
# check that everything has units
Expand Down
2 changes: 1 addition & 1 deletion mdtraj/formats/hoomdxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def load_hoomdxml(filename, top=None):
xy = float(box.attrib['xy'])
xz = float(box.attrib['xz'])
yz = float(box.attrib['yz'])
except:
except (ValueError, KeyError):
xy = 0.0
xz = 0.0
yz = 0.0
Expand Down
2 changes: 1 addition & 1 deletion mdtraj/formats/pdb/pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _is_url(url):
"""
try:
return urlparse(url).scheme in _VALID_URLS
except:
except (AttributeError, TypeError):
return False


Expand Down
15 changes: 8 additions & 7 deletions mdtraj/formats/pdb/pdbstructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def _load(self, input_stream):
for pos in (11,16,21,26):
try:
atoms.append(int(pdb_line[pos:pos+5]))
except:
except ValueError:
# Optional field, don't worry if it isn't defined
pass

self._current_model.connects.append(atoms)
Expand Down Expand Up @@ -679,11 +680,11 @@ def __init__(self, pdb_line, pdbstructure=None):
else:
try:
self.serial_number = int(pdb_line[6:11])
except:
except ValueError:
try:
self.serial_number = int(pdb_line[6:11], 16)
pdbstructure._atom_numbers_are_hex = True
except:
except ValueError:
# Just give it the next number in sequence.
self.serial_number = pdbstructure._next_atom_number
self.name_with_spaces = pdb_line[12:16]
Expand All @@ -706,11 +707,11 @@ def __init__(self, pdb_line, pdbstructure=None):
else:
try:
self.residue_number = int(pdb_line[22:26])
except:
except ValueError:
try:
self.residue_number = int(pdb_line[22:26], 16)
pdbstructure._residue_numbers_are_hex = True
except:
except ValueError:
# When VMD runs out of hex values it starts filling in the residue ID field with ****
# Look at the most recent atoms to figure out whether this is a new residue or not.
if pdbstructure._current_model is None or pdbstructure._current_model._current_chain is None or pdbstructure._current_model._current_chain._current_residue is None:
Expand All @@ -733,11 +734,11 @@ def __init__(self, pdb_line, pdbstructure=None):
z = float(pdb_line[46:54])
try:
occupancy = float(pdb_line[54:60])
except:
except ValueError:
occupancy = 1.0
try:
temperature_factor = float(pdb_line[60:66])
except:
except ValueError:
temperature_factor = 0.0
self.locations = {}
loc = Atom.Location(alternate_location_indicator, np.array([x,y,z]), occupancy, temperature_factor, self.residue_name_with_spaces)
Expand Down

0 comments on commit 47a85ef

Please sign in to comment.