Skip to content

Commit

Permalink
Squashed 'modules/pmi/' changes from f7bcfd722d..198598f5c8
Browse files Browse the repository at this point in the history
198598f5c8 Remove Python 2 workaround for TestCase.assertWarns
54b555a73b More Python 2 cleanups
9c20cd1755 Use no-argument form of super()
bc6ab67368 Drop Python 2 compatibility
75c8a62ff7 Squashed 'tools/dev_tools/' changes from 3ad5e0d8..c2d08a83

git-subtree-dir: modules/pmi
git-subtree-split: 198598f5c85a35bb01ccd0798d22f25456fe4008
  • Loading branch information
benmwebb committed Jun 5, 2024
1 parent 41b1236 commit 631fc2c
Show file tree
Hide file tree
Showing 41 changed files with 221 additions and 281 deletions.
7 changes: 2 additions & 5 deletions modules/pmi/benchmark/benchmark_loop_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import time
import sys
import os
try:
from time import process_time # needs python 3.3 or later
except ImportError:
from time import clock as process_time
from time import process_time

import IMP.pmi.restraints.stereochemistry
import IMP.pmi.topology
Expand All @@ -26,7 +23,7 @@
# Redirect chatty PMI output so we can see benchmark output
old_stdout = sys.stdout

class DummyFile(object):
class DummyFile:
def flush(self):
pass
def write(self, txt):
Expand Down
7 changes: 2 additions & 5 deletions modules/pmi/benchmark/benchmark_replica_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@
import time
import sys
import shutil
try:
from time import process_time # needs python 3.3 or later
except ImportError:
from time import clock as process_time
from time import process_time


IMP.setup_from_argv(sys.argv, "Replica exchange benchmark.")
IMP.set_log_level(IMP.SILENT)
old_stdout = sys.stdout
class DummyFile(object):
class DummyFile:
def flush(self):
pass
def write(self, txt):
Expand Down
2 changes: 1 addition & 1 deletion modules/pmi/pyext/src/alphabets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import IMP.atom


class ResidueAlphabet(object):
class ResidueAlphabet:
"""Map between FASTA codes and residue types.
Typically one would use the `amino_acid`, `rna`, or `dna` objects."""
def __init__(self, charmm_to_one, chain_type=IMP.atom.UnknownChainType):
Expand Down
16 changes: 8 additions & 8 deletions modules/pmi/pyext/src/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np


class Alignment(object):
class Alignment:
"""Performs alignment and RMSD calculation for two sets of coordinates
The class also takes into account non-equal stoichiometry of the proteins.
Expand Down Expand Up @@ -151,7 +151,7 @@ def align(self):


# ----------------------------------
class Violations(object):
class Violations:

def __init__(self, filename):

Expand Down Expand Up @@ -180,7 +180,7 @@ def get_number_violated_restraints(self, rsts_dict):
return num_violated


class Clustering(object):
class Clustering:
"""A class to cluster structures.
Uses scipy's cdist function to compute distance matrices
and sklearn's kmeans clustering module.
Expand Down Expand Up @@ -458,7 +458,7 @@ def matrix_calculation(self, all_coords, template_coords, list_of_pairs):
return raw_distance_dict, transformation_distance_dict


class RMSD(object):
class RMSD:
"""Compute the RMSD (without alignment) taking into account the copy
ambiguity.
To be used with pmi2 hierarchies. Can be used for instance as follows:
Expand Down Expand Up @@ -592,7 +592,7 @@ def get_output(self):
"RMSD_assignments_" + self.label: str(assignments_out)}


class Precision(object):
class Precision:
"""A class to evaluate the precision of an ensemble.
Also can evaluate the cross-precision of multiple ensembles.
Expand Down Expand Up @@ -1151,7 +1151,7 @@ def set_precision_style(self, style):
raise ValueError("No such style")


class GetModelDensity(object):
class GetModelDensity:
"""Compute mean density maps from structures.
Keeps a dictionary of density maps,
Expand Down Expand Up @@ -1275,7 +1275,7 @@ def write_mrc(self, path="./", suffix=None):
IMP.em.MRCReaderWriter())


class GetContactMap(object):
class GetContactMap:

def __init__(self, distance=15.):
self.distance = distance
Expand Down Expand Up @@ -1627,7 +1627,7 @@ def get_particles_at_resolution_ten(prot):
return particle_dict


class CrossLinkTable(object):
class CrossLinkTable:
"""Visualization of cross-links"""
def __init__(self):
self.crosslinks = []
Expand Down
2 changes: 1 addition & 1 deletion modules/pmi/pyext/src/dof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create_rigid_body_movers(dof, maxtrans, maxrot):
return mvs


class DegreesOfFreedom(object):
class DegreesOfFreedom:
"""Simplify creation of constraints and movers for an IMP Hierarchy.
* The various "create X" functions make movers for system components
Expand Down
4 changes: 2 additions & 2 deletions modules/pmi/pyext/src/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def save_best_models(model, out_dir, stat_files,
print('wrote rmfs to', out_rmf_fn)


class _TempProvenance(object):
class _TempProvenance:
"""Placeholder to track provenance information added to the IMP model.
This is since we typically don't preserve the IMP::Model object
throughout a PMI protocol."""
Expand Down Expand Up @@ -541,7 +541,7 @@ def get_bead_sizes(model, rmf_tuple, rmsd_calculation_components=None,
return rmsd_bead_size_dict


class TotalScoreOutput(object):
class TotalScoreOutput:
"""A helper output for model evaluation"""
def __init__(self, model):
self.model = model
Expand Down
10 changes: 5 additions & 5 deletions modules/pmi/pyext/src/io/crosslink.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _handle_string_input(inp):
return inp


class _CrossLinkDataBaseStandardKeys(object):
class _CrossLinkDataBaseStandardKeys:
'''
This class setup all the standard keys needed to
identify the cross-link features from the data sets
Expand Down Expand Up @@ -197,7 +197,7 @@ def __str__(self):
return outstr


class FilterOperator(object):
class FilterOperator:
'''
This class allows to create filter functions that can be passed to
the CrossLinkDataBase in this way:
Expand Down Expand Up @@ -1397,7 +1397,7 @@ def get_number_of_unique_crosslinked_sites(self):
return len(list(praset))


class JaccardDistanceMatrix(object):
class JaccardDistanceMatrix:
"""This class allows to compute and plot the distance between datasets"""

def __init__(self, cldb_dictionary):
Expand Down Expand Up @@ -1480,7 +1480,7 @@ def plot_matrix(self, figurename="clustermatrix.pdf"):
pl.close(fig)


class MapCrossLinkDataBaseOnStructure(object):
class MapCrossLinkDataBaseOnStructure:
'''
This class maps a CrossLinkDataBase on a given structure
and save an rmf file with color-coded cross-links
Expand Down Expand Up @@ -1684,7 +1684,7 @@ def get_crosslink_violations(self, threshold):
return violations


class CrossLinkDataBaseFromStructure(object):
class CrossLinkDataBaseFromStructure:
'''
This class generates a CrossLinkDataBase from a given structure
'''
Expand Down
15 changes: 7 additions & 8 deletions modules/pmi/pyext/src/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
import pickle


class _MockMPIValues(object):
class _MockMPIValues:
"""Replace samplers.MPI_values when in test mode"""
def get_percentile(self, name):
return 0.


class _RMFRestraints(object):
class _RMFRestraints:
"""All restraints that are written out to the RMF file"""
def __init__(self, model, user_restraints):
self._rmf_rs = IMP.pmi.tools.get_restraint_set(model, rmf=True)
Expand All @@ -43,10 +43,9 @@ def __len__(self):

def __bool__(self):
return len(self) > 0
__nonzero__ = __bool__ # Python 2 compatibility

def __getitem__(self, i):
class FakePMIWrapper(object):
class FakePMIWrapper:
def __init__(self, r):
self.r = IMP.RestraintSet.get_from(r)

Expand All @@ -63,7 +62,7 @@ def get_restraint(self):
raise IndexError("Out of range")


class ReplicaExchange(object):
class ReplicaExchange:
"""A macro to help setup and run replica exchange.
Supports Monte Carlo and molecular dynamics.
Produces trajectory RMF files, best PDB structures,
Expand Down Expand Up @@ -628,7 +627,7 @@ def execute_macro(self):
output.close_rmf(rmfname)


class BuildSystem(object):
class BuildSystem:
"""A macro to build a IMP::pmi::topology::System based on a
TopologyReader object.
Expand Down Expand Up @@ -935,7 +934,7 @@ def execute_macro(self, max_rb_trans=4.0, max_rb_rot=0.04,


@IMP.deprecated_object("2.8", "Use AnalysisReplicaExchange instead")
class AnalysisReplicaExchange0(object):
class AnalysisReplicaExchange0:
"""A macro for running all the basic operations of analysis.
Includes clustering, precision analysis, and making ensemble density maps.
A number of plots are also supported.
Expand Down Expand Up @@ -1621,7 +1620,7 @@ def load_objects(self, file_name):
return objects


class AnalysisReplicaExchange(object):
class AnalysisReplicaExchange:

"""
This class contains analysis utilities to investigate ReplicaExchange
Expand Down
Loading

0 comments on commit 631fc2c

Please sign in to comment.