From b8da45603e22414999dab0298fa0d66418759f94 Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Tue, 11 Jun 2019 18:16:02 -0400
Subject: [PATCH 1/6] Closes #92 by calculating trajectories for entire
 profiles.

---
 idpflex/properties.py                    |   2 +
 idpflex/utils.py                         |  62 ++-
 tests/conftest.py                        |  10 +-
 tests/data/sans/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/data/saxs/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/test_utils.py                      |  20 +
 6 files changed, 1086 insertions(+), 8 deletions(-)
 create mode 100644 tests/data/sans/trajectory_3_profile.dat
 create mode 100644 tests/data/saxs/trajectory_3_profile.dat

diff --git a/idpflex/properties.py b/idpflex/properties.py
index 169a630..6045add 100644
--- a/idpflex/properties.py
+++ b/idpflex/properties.py
@@ -1351,6 +1351,7 @@ class SansProperty(ProfileProperty, SansLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_cryson_pdb
         if self.name is None:
             self.name = SansProperty.default_name
 
@@ -1489,6 +1490,7 @@ class SaxsProperty(ProfileProperty, SaxsLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_crysol_pdb
         if self.name is None:
             self.name = SaxsProperty.default_name
 
diff --git a/idpflex/utils.py b/idpflex/utils.py
index fb1e54a..10bcbbd 100644
--- a/idpflex/utils.py
+++ b/idpflex/utils.py
@@ -2,33 +2,34 @@
 from contextlib import contextmanager
 import tempfile
 import functools
+import multiprocessing
 from collections import namedtuple, Mapping
 
 import MDAnalysis as mda
 
 
-def write_frame(a_universe, iframe, file_name):
+def write_frame(atom_group, iframe, file_name):
     r"""Write a single trajectory frame to file.
 
     Format is guessed from the file's extension.
 
     Parameters
     ----------
-    a_universe : :class:`~MDAnalysis.core.universe.Universe`
-        Universe describing the simulation
+    atom_group : :class:`~MDAnalysis.AtomGroup`
+        Atoms from the universe describing the simulation
     iframe : int
         Trajectory frame index (indexes begin with zero)
     file_name : str
         Name of the file to create
     """
-    a_universe.trajectory[iframe]
+    atom_group.universe.trajectory[iframe]
     # Create directory if not existing
     dir_name = os.path.dirname(file_name)
     if dir_name and not os.path.isdir(dir_name):
         os.makedirs(dir_name)
 
     with mda.Writer(file_name) as writer:
-        writer.write(a_universe)
+        writer.write(atom_group)
 
 
 @contextmanager
@@ -58,7 +59,7 @@ def namedtuplefy(func):
 
     Parameters
     ----------
-    func: Function
+    func: function
         Function to be decorated
     name: str
         Class name for the namedtuple. If None, the name of the function
@@ -78,3 +79,52 @@ def wrapper(*args, **kwargs):
         return wrapper.nt(**res)
     wrapper.nt = None
     return wrapper
+
+
+def generate_profile_for_frame(atom_group, iframe, profile_class):
+    r"""
+    Utility function to generate profile properties for a frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframe: int
+        The index of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    Profile for the selected frame
+    """  # noqa: E501
+    with temporary_file(suffix='.pdb') as fname:
+        # Copy the atom group to a new universe to avoid
+        # changing frames upon writing
+        u = atom_group.universe
+        u2 = mda.Universe(u.filename, u.trajectory.filename)
+        atoms2 = u2.atoms[atom_group.atoms.indices]
+        write_frame(atoms2, iframe, fname)
+        return profile_class().from_pdb(fname)
+
+
+def generate_trajectory_profiles(atom_group, iframes, profile_class):
+    r"""
+    Utility function to generate profile properties for each frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframes: List[int]
+        The indices of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    List of the profiles.
+    """  # noqa: E501
+    with multiprocessing.Pool() as p:
+        return p.starmap(generate_profile_for_frame,
+                         [(atom_group, i, profile_class) for i in iframes])
diff --git a/tests/conftest.py b/tests/conftest.py
index 3f42d90..9d58f5b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -106,14 +106,17 @@ def saxs_benchmark():
         'crysol_pdb': absolute path to file.
         'crysol_int': absolute path to file.
         'crysol_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     crysol_file = os.path.join(data_dir, 'saxs', 'crysol.dat')
     crysol_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     crysol_int = os.path.join(data_dir, 'saxs', 'md_0_100.int')
     crysol_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'saxs', 'trajectory_3_profile.dat')
     return dict(crysol_file=crysol_file, crysol_pdb=crysol_pdb,
-                crysol_int=crysol_int, crysol_xtc=crysol_xtc)
+                crysol_int=crysol_int, crysol_xtc=crysol_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
@@ -130,6 +133,7 @@ def sans_benchmark(request):
         'cryson_pdb': absolute path to file.
         'cryson_int': absolute path to file.
         'cryson_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     # setup or initialization
@@ -153,13 +157,15 @@ def sans_benchmark(request):
     cryson_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     cryson_int = os.path.join(data_dir, 'sans', 'md_0_100.int')
     cryson_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'sans', 'trajectory_3_profile.dat')
 
     def teardown():
         handle.close()
     request.addfinalizer(teardown)
     return dict(profiles=handle, property_list=values,
                 tree_with_no_property=tree, cryson_pdb=cryson_pdb,
-                cryson_int=cryson_int, cryson_xtc=cryson_xtc)
+                cryson_int=cryson_int, cryson_xtc=cryson_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
diff --git a/tests/data/sans/trajectory_3_profile.dat b/tests/data/sans/trajectory_3_profile.dat
new file mode 100644
index 0000000..d4af149
--- /dev/null
+++ b/tests/data/sans/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+5.802240000000000000e+05
+5.801650000000000000e+05
+5.800010000000000000e+05
+5.797260000000000000e+05
+5.793430000000000000e+05
+5.788500000000000000e+05
+5.782480000000000000e+05
+5.775380000000000000e+05
+5.767190000000000000e+05
+5.757930000000000000e+05
+5.747590000000000000e+05
+5.736180000000000000e+05
+5.723720000000000000e+05
+5.710190000000000000e+05
+5.695630000000000000e+05
+5.680020000000000000e+05
+5.663380000000000000e+05
+5.645710000000000000e+05
+5.627040000000000000e+05
+5.607360000000000000e+05
+5.586690000000000000e+05
+5.565050000000000000e+05
+5.542430000000000000e+05
+5.518850000000000000e+05
+5.494330000000000000e+05
+5.468880000000000000e+05
+5.442510000000000000e+05
+5.415230000000000000e+05
+5.387060000000000000e+05
+5.358020000000000000e+05
+5.328110000000000000e+05
+5.297360000000000000e+05
+5.265780000000000000e+05
+5.233390000000000000e+05
+5.200210000000000000e+05
+5.166240000000000000e+05
+5.131510000000000000e+05
+5.096030000000000000e+05
+5.059830000000000000e+05
+5.022920000000000000e+05
+4.985320000000000000e+05
+4.947050000000000000e+05
+4.908130000000000000e+05
+4.868570000000000000e+05
+4.828400000000000000e+05
+4.787640000000000000e+05
+4.746300000000000000e+05
+4.704400000000000000e+05
+4.661980000000000000e+05
+4.619030000000000000e+05
+4.575600000000000000e+05
+4.531690000000000000e+05
+4.487330000000000000e+05
+4.442530000000000000e+05
+4.397330000000000000e+05
+4.351730000000000000e+05
+4.305760000000000000e+05
+4.259450000000000000e+05
+4.212800000000000000e+05
+4.165850000000000000e+05
+4.118610000000000000e+05
+4.071100000000000000e+05
+4.023350000000000000e+05
+3.975370000000000000e+05
+3.927190000000000000e+05
+3.878820000000000000e+05
+3.830290000000000000e+05
+3.781610000000000000e+05
+3.732810000000000000e+05
+3.683900000000000000e+05
+3.634910000000000000e+05
+3.585860000000000000e+05
+3.536750000000000000e+05
+3.487620000000000000e+05
+3.438480000000000000e+05
+3.389350000000000000e+05
+3.340250000000000000e+05
+3.291190000000000000e+05
+3.242200000000000000e+05
+3.193290000000000000e+05
+3.144480000000000000e+05
+3.095790000000000000e+05
+3.047220000000000000e+05
+2.998810000000000000e+05
+2.950570000000000000e+05
+2.902500000000000000e+05
+2.854630000000000000e+05
+2.806970000000000000e+05
+2.759540000000000000e+05
+2.712350000000000000e+05
+2.665420000000000000e+05
+2.618750000000000000e+05
+2.572370000000000000e+05
+2.526280000000000000e+05
+2.480500000000000000e+05
+2.435050000000000000e+05
+2.389920000000000000e+05
+2.345140000000000000e+05
+2.300710000000000000e+05
+2.256650000000000000e+05
+2.212960000000000000e+05
+2.169660000000000000e+05
+2.126760000000000000e+05
+2.084260000000000000e+05
+2.042180000000000000e+05
+2.000520000000000000e+05
+1.959290000000000000e+05
+1.918490000000000000e+05
+1.878150000000000000e+05
+1.838250000000000000e+05
+1.798820000000000000e+05
+1.759850000000000000e+05
+1.721350000000000000e+05
+1.683330000000000000e+05
+1.645790000000000000e+05
+1.608740000000000000e+05
+1.572180000000000000e+05
+1.536110000000000000e+05
+1.500540000000000000e+05
+1.465480000000000000e+05
+1.430910000000000000e+05
+1.396860000000000000e+05
+1.363310000000000000e+05
+1.330280000000000000e+05
+1.297760000000000000e+05
+1.265750000000000000e+05
+1.234260000000000000e+05
+1.203280000000000000e+05
+1.172820000000000000e+05
+1.142870000000000000e+05
+1.113450000000000000e+05
+1.084530000000000000e+05
+1.056130000000000000e+05
+1.028250000000000000e+05
+1.000870000000000000e+05
+9.740100000000000000e+04
+9.476550000000000000e+04
+9.218060000000000582e+04
+8.964610000000000582e+04
+8.716169999999999709e+04
+8.472719999999999709e+04
+8.234219999999999709e+04
+8.000639999999999418e+04
+7.771950000000000000e+04
+7.548110000000000582e+04
+7.329080000000000291e+04
+7.114819999999999709e+04
+6.905289999999999418e+04
+6.700450000000000000e+04
+6.500250000000000000e+04
+6.304640000000000146e+04
+6.113580000000000291e+04
+5.927019999999999709e+04
+5.744900000000000000e+04
+5.567180000000000291e+04
+5.393800000000000000e+04
+5.224709999999999854e+04
+5.059840000000000146e+04
+4.899159999999999854e+04
+4.742590000000000146e+04
+4.590080000000000291e+04
+4.441580000000000291e+04
+4.297009999999999854e+04
+4.156330000000000291e+04
+4.019469999999999709e+04
+3.886369999999999709e+04
+3.756980000000000291e+04
+3.631219999999999709e+04
+3.509030000000000291e+04
+3.390359999999999854e+04
+3.275140000000000146e+04
+3.163309999999999854e+04
+3.054800000000000000e+04
+2.949550000000000000e+04
+2.847500000000000000e+04
+2.748590000000000146e+04
+2.652750000000000000e+04
+2.559920000000000073e+04
+2.470040000000000146e+04
+2.383040000000000146e+04
+2.298870000000000073e+04
+2.217459999999999854e+04
+2.138740000000000146e+04
+2.062670000000000073e+04
+1.989170000000000073e+04
+1.918190000000000146e+04
+1.849670000000000073e+04
+1.783540000000000146e+04
+1.719750000000000000e+04
+1.658250000000000000e+04
+1.598960000000000036e+04
+1.541839999999999964e+04
+1.486829999999999927e+04
+1.433879999999999927e+04
+1.382920000000000073e+04
+1.333900000000000000e+04
+1.286779999999999927e+04
+1.241489999999999964e+04
+1.197989999999999964e+04
+1.156210000000000036e+04
+1.116120000000000073e+04
+1.077660000000000036e+04
+1.040789999999999964e+04
+1.005439999999999964e+04
+9.715879999999999200e+03
+9.391700000000000728e+03
+9.081459999999999127e+03
+8.784700000000000728e+03
+8.500969999999999345e+03
+8.229850000000000364e+03
+7.970909999999999854e+03
+7.723729999999999563e+03
+7.487890000000000327e+03
+7.263000000000000000e+03
+7.048659999999999854e+03
+6.844489999999999782e+03
+6.650119999999999891e+03
+6.465170000000000073e+03
+6.289300000000000182e+03
+6.122140000000000327e+03
+5.963359999999999673e+03
+5.812619999999999891e+03
+5.669590000000000146e+03
+5.533970000000000255e+03
+5.405439999999999600e+03
+5.283699999999999818e+03
+5.168449999999999818e+03
+5.059409999999999854e+03
+4.956319999999999709e+03
+4.858880000000000109e+03
+4.766840000000000146e+03
+4.679949999999999818e+03
+4.597960000000000036e+03
+4.520630000000000109e+03
+4.447729999999999563e+03
+4.379050000000000182e+03
+4.314340000000000146e+03
+4.253409999999999854e+03
+4.196050000000000182e+03
+4.142060000000000400e+03
+4.091250000000000000e+03
+4.043440000000000055e+03
+3.998449999999999818e+03
+3.956110000000000127e+03
+3.916250000000000000e+03
+3.878719999999999800e+03
+3.843349999999999909e+03
+3.810019999999999982e+03
+3.778550000000000182e+03
+3.748829999999999927e+03
+3.720719999999999800e+03
+3.694090000000000146e+03
+3.668820000000000164e+03
+3.644820000000000164e+03
+3.621940000000000055e+03
+3.600110000000000127e+03
+3.579210000000000036e+03
+3.559150000000000091e+03
+3.539820000000000164e+03
+3.521159999999999854e+03
+3.503079999999999927e+03
+3.485500000000000000e+03
+3.468329999999999927e+03
+3.451519999999999982e+03
+3.434989999999999782e+03
+3.418679999999999836e+03
+3.402539999999999964e+03
+3.386500000000000000e+03
+3.370519999999999982e+03
+3.354539999999999964e+03
+3.338510000000000218e+03
+3.322409999999999854e+03
+3.306179999999999836e+03
+3.289800000000000182e+03
+3.273210000000000036e+03
+3.256400000000000091e+03
+3.239340000000000146e+03
+3.221989999999999782e+03
+3.204349999999999909e+03
+3.186369999999999891e+03
+3.168050000000000182e+03
+3.149380000000000109e+03
+3.130309999999999945e+03
+3.110860000000000127e+03
+3.091010000000000218e+03
+3.070760000000000218e+03
+3.050099999999999909e+03
+3.029010000000000218e+03
+3.007500000000000000e+03
+2.985559999999999945e+03
+2.963190000000000055e+03
+2.940409999999999854e+03
+2.917190000000000055e+03
+2.893559999999999945e+03
+2.869519999999999982e+03
+2.845059999999999945e+03
+2.820210000000000036e+03
+2.794969999999999800e+03
+2.769340000000000146e+03
+2.743340000000000146e+03
+2.716969999999999800e+03
+2.690239999999999782e+03
+2.663190000000000055e+03
+2.635820000000000164e+03
+2.608130000000000109e+03
+2.580150000000000091e+03
+2.551889999999999873e+03
+2.523349999999999909e+03
+2.494579999999999927e+03
+2.465559999999999945e+03
+2.436340000000000146e+03
+2.406909999999999854e+03
+2.377300000000000182e+03
+2.347519999999999982e+03
+2.317599999999999909e+03
+2.287550000000000182e+03
+2.257380000000000109e+03
+2.227119999999999891e+03
+2.196789999999999964e+03
+2.166409999999999854e+03
+2.135989999999999782e+03
+2.105550000000000182e+03
+2.075110000000000127e+03
+2.044690000000000055e+03
+2.014289999999999964e+03
+1.983960000000000036e+03
+1.953710000000000036e+03
+1.923529999999999973e+03
+1.893460000000000036e+03
+1.863509999999999991e+03
+1.833710000000000036e+03
+1.804049999999999955e+03
+1.774569999999999936e+03
+1.745259999999999991e+03
+1.716180000000000064e+03
+1.687299999999999955e+03
+1.658650000000000091e+03
+1.630250000000000000e+03
+1.602109999999999900e+03
+1.574250000000000000e+03
+1.546670000000000073e+03
+1.519390000000000100e+03
+1.492440000000000055e+03
+1.465799999999999955e+03
+1.439490000000000009e+03
+1.413519999999999982e+03
+1.387910000000000082e+03
+1.362670000000000073e+03
+1.337799999999999955e+03
+1.313309999999999945e+03
+1.289220000000000027e+03
+1.265529999999999973e+03
+1.242240000000000009e+03
+1.219359999999999900e+03
+1.196900000000000091e+03
+1.174880000000000109e+03
+1.153279999999999973e+03
+1.132109999999999900e+03
+1.111380000000000109e+03
+1.091099999999999909e+03
+1.071259999999999991e+03
+1.051869999999999891e+03
+1.032940000000000055e+03
+1.014460000000000036e+03
+9.964370000000000118e+02
+9.788659999999999854e+02
+9.617509999999999764e+02
+9.450940000000000509e+02
+9.288959999999999582e+02
+9.131539999999999964e+02
+8.978579999999999472e+02
+8.830199999999999818e+02
+8.686309999999999718e+02
+8.546960000000000264e+02
+8.412010000000000218e+02
+8.281559999999999491e+02
+8.155470000000000255e+02
+8.033750000000000000e+02
+7.916319999999999482e+02
+7.803170000000000073e+02
+7.694260000000000446e+02
+7.589539999999999509e+02
+7.488949999999999818e+02
+7.392390000000000327e+02
+7.299819999999999709e+02
+7.211159999999999854e+02
+7.126430000000000291e+02
+7.045470000000000255e+02
+6.968310000000000173e+02
+6.894800000000000182e+02
+6.824900000000000091e+02
+6.758569999999999709e+02
+6.695539999999999736e+02
+6.636000000000000227e+02
+6.579759999999999991e+02
+6.526710000000000491e+02
+6.476839999999999691e+02
+6.430069999999999482e+02
+6.386230000000000473e+02
+6.345380000000000109e+02
+6.307219999999999800e+02
+6.271839999999999691e+02
+6.239109999999999445e+02
+6.208949999999999818e+02
+6.181130000000000564e+02
+6.155750000000000455e+02
+6.132609999999999673e+02
+6.111749999999999545e+02
+6.093049999999999500e+02
+6.076230000000000473e+02
+6.061449999999999818e+02
+6.048609999999999900e+02
+6.037649999999999864e+02
+6.028260000000000218e+02
+6.020579999999999927e+02
+6.014349999999999454e+02
+6.009569999999999936e+02
+6.006299999999999955e+02
+6.004329999999999927e+02
+6.003479999999999563e+02
+6.003840000000000146e+02
+6.005249999999999773e+02
+6.007680000000000291e+02
+6.011040000000000418e+02
+6.015270000000000437e+02
+6.020240000000000009e+02
+6.025940000000000509e+02
+6.032309999999999945e+02
+6.039210000000000491e+02
+6.046649999999999636e+02
+6.054539999999999509e+02
+6.062899999999999636e+02
+6.071589999999999918e+02
+6.080460000000000491e+02
+6.089679999999999609e+02
+6.099109999999999445e+02
+6.108600000000000136e+02
+6.118160000000000309e+02
+6.127690000000000055e+02
+6.137329999999999472e+02
+6.146860000000000355e+02
+6.156290000000000191e+02
+6.165549999999999500e+02
+6.174610000000000127e+02
+6.183410000000000082e+02
+6.192000000000000455e+02
+6.200349999999999682e+02
+6.208339999999999463e+02
+6.216090000000000373e+02
+6.223390000000000555e+02
+6.230399999999999636e+02
+6.236839999999999691e+02
+6.242839999999999918e+02
+6.248379999999999654e+02
+6.253460000000000036e+02
+6.258070000000000164e+02
+6.262100000000000364e+02
+6.265629999999999882e+02
+6.268690000000000282e+02
+6.271159999999999854e+02
+6.273060000000000400e+02
+6.274339999999999691e+02
+6.275090000000000146e+02
+6.275199999999999818e+02
+6.274750000000000227e+02
+6.273640000000000327e+02
+6.272019999999999982e+02
+6.269859999999999900e+02
+6.267129999999999654e+02
+6.263740000000000236e+02
+6.259829999999999472e+02
+6.255389999999999873e+02
+6.250420000000000300e+02
+6.244900000000000091e+02
+6.238790000000000191e+02
+6.232110000000000127e+02
+6.224919999999999618e+02
+6.217190000000000509e+02
+6.209020000000000437e+02
+6.200330000000000155e+02
+6.191109999999999900e+02
+6.181499999999999773e+02
+6.171359999999999673e+02
+6.160839999999999463e+02
+6.149829999999999472e+02
+6.138429999999999609e+02
+6.126649999999999636e+02
+6.114560000000000173e+02
+6.102129999999999654e+02
+6.089270000000000209e+02
+6.076250000000000000e+02
+6.062740000000000009e+02
+6.049009999999999536e+02
+6.035019999999999527e+02
+6.020819999999999936e+02
+6.006319999999999482e+02
+5.991689999999999827e+02
+5.976789999999999736e+02
+5.961749999999999545e+02
+5.946499999999999773e+02
diff --git a/tests/data/saxs/trajectory_3_profile.dat b/tests/data/saxs/trajectory_3_profile.dat
new file mode 100644
index 0000000..effca13
--- /dev/null
+++ b/tests/data/saxs/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+8.128970000000000000e+06
+8.127820000000000000e+06
+8.124460000000000000e+06
+8.118860000000000000e+06
+8.111030000000000000e+06
+8.100960000000000000e+06
+8.088680000000000000e+06
+8.074190000000000000e+06
+8.057500000000000000e+06
+8.038620000000000000e+06
+8.017570000000000000e+06
+7.994370000000000000e+06
+7.969010000000000000e+06
+7.941560000000000000e+06
+7.912050000000000000e+06
+7.880380000000000000e+06
+7.846770000000000000e+06
+7.811090000000000000e+06
+7.773290000000000000e+06
+7.733740000000000000e+06
+7.692170000000000000e+06
+7.648590000000000000e+06
+7.603150000000000000e+06
+7.555830000000000000e+06
+7.506850000000000000e+06
+7.455980000000000000e+06
+7.403430000000000000e+06
+7.349180000000000000e+06
+7.293250000000000000e+06
+7.235750000000000000e+06
+7.176640000000000000e+06
+7.116040000000000000e+06
+7.053900000000000000e+06
+6.990350000000000000e+06
+6.925400000000000000e+06
+6.859120000000000000e+06
+6.791510000000000000e+06
+6.722650000000000000e+06
+6.652600000000000000e+06
+6.581370000000000000e+06
+6.509050000000000000e+06
+6.435670000000000000e+06
+6.361270000000000000e+06
+6.285910000000000000e+06
+6.209630000000000000e+06
+6.132510000000000000e+06
+6.054570000000000000e+06
+5.975880000000000000e+06
+5.896470000000000000e+06
+5.816410000000000000e+06
+5.735750000000000000e+06
+5.654530000000000000e+06
+5.572820000000000000e+06
+5.490650000000000000e+06
+5.408070000000000000e+06
+5.325140000000000000e+06
+5.241910000000000000e+06
+5.158420000000000000e+06
+5.074740000000000000e+06
+4.990890000000000000e+06
+4.906940000000000000e+06
+4.822920000000000000e+06
+4.738890000000000000e+06
+4.654890000000000000e+06
+4.570970000000000000e+06
+4.487180000000000000e+06
+4.403540000000000000e+06
+4.320120000000000000e+06
+4.236940000000000000e+06
+4.154060000000000000e+06
+4.071520000000000000e+06
+3.989340000000000000e+06
+3.907580000000000000e+06
+3.826270000000000000e+06
+3.745440000000000000e+06
+3.665130000000000000e+06
+3.585390000000000000e+06
+3.506230000000000000e+06
+3.427700000000000000e+06
+3.349820000000000000e+06
+3.272630000000000000e+06
+3.196160000000000000e+06
+3.120430000000000000e+06
+3.045470000000000000e+06
+2.971310000000000000e+06
+2.897970000000000000e+06
+2.825480000000000000e+06
+2.753850000000000000e+06
+2.683120000000000000e+06
+2.613300000000000000e+06
+2.544400000000000000e+06
+2.476460000000000000e+06
+2.409480000000000000e+06
+2.343480000000000000e+06
+2.278480000000000000e+06
+2.214490000000000000e+06
+2.151520000000000000e+06
+2.089580000000000000e+06
+2.028690000000000000e+06
+1.968840000000000000e+06
+1.910060000000000000e+06
+1.852350000000000000e+06
+1.795710000000000000e+06
+1.740150000000000000e+06
+1.685680000000000000e+06
+1.632290000000000000e+06
+1.579980000000000000e+06
+1.528770000000000000e+06
+1.478650000000000000e+06
+1.429610000000000000e+06
+1.381670000000000000e+06
+1.334800000000000000e+06
+1.289020000000000000e+06
+1.244320000000000000e+06
+1.200690000000000000e+06
+1.158130000000000000e+06
+1.116630000000000000e+06
+1.076180000000000000e+06
+1.036770000000000000e+06
+9.984100000000000000e+05
+9.610740000000000000e+05
+9.247570000000000000e+05
+8.894490000000000000e+05
+8.551380000000000000e+05
+8.218150000000000000e+05
+7.894660000000000000e+05
+7.580790000000000000e+05
+7.276430000000000000e+05
+6.981430000000000000e+05
+6.695670000000000000e+05
+6.419000000000000000e+05
+6.151280000000000000e+05
+5.892370000000000000e+05
+5.642120000000000000e+05
+5.400370000000000000e+05
+5.166980000000000000e+05
+4.941770000000000000e+05
+4.724610000000000000e+05
+4.515330000000000000e+05
+4.313770000000000000e+05
+4.119760000000000000e+05
+3.933140000000000000e+05
+3.753750000000000000e+05
+3.581430000000000000e+05
+3.416000000000000000e+05
+3.257310000000000000e+05
+3.105180000000000000e+05
+2.959450000000000000e+05
+2.819960000000000000e+05
+2.686530000000000000e+05
+2.559010000000000000e+05
+2.437240000000000000e+05
+2.321050000000000000e+05
+2.210270000000000000e+05
+2.104750000000000000e+05
+2.004340000000000000e+05
+1.908870000000000000e+05
+1.818180000000000000e+05
+1.732120000000000000e+05
+1.650550000000000000e+05
+1.573310000000000000e+05
+1.500240000000000000e+05
+1.431220000000000000e+05
+1.366090000000000000e+05
+1.304700000000000000e+05
+1.246940000000000000e+05
+1.192640000000000000e+05
+1.141680000000000000e+05
+1.093940000000000000e+05
+1.049270000000000000e+05
+1.007560000000000000e+05
+9.686700000000000000e+04
+9.324910000000000582e+04
+8.989030000000000291e+04
+8.677860000000000582e+04
+8.390319999999999709e+04
+8.125269999999999709e+04
+7.881660000000000582e+04
+7.658430000000000291e+04
+7.454569999999999709e+04
+7.269089999999999418e+04
+7.101030000000000291e+04
+6.949450000000000000e+04
+6.813450000000000000e+04
+6.692150000000000000e+04
+6.584710000000000582e+04
+6.490269999999999709e+04
+6.408100000000000000e+04
+6.337380000000000291e+04
+6.277369999999999709e+04
+6.227380000000000291e+04
+6.186709999999999854e+04
+6.154690000000000146e+04
+6.130669999999999709e+04
+6.114059999999999854e+04
+6.104240000000000146e+04
+6.100659999999999854e+04
+6.102759999999999854e+04
+6.110040000000000146e+04
+6.122000000000000000e+04
+6.138140000000000146e+04
+6.158030000000000291e+04
+6.181230000000000291e+04
+6.207340000000000146e+04
+6.235980000000000291e+04
+6.266700000000000000e+04
+6.299240000000000146e+04
+6.333200000000000000e+04
+6.368290000000000146e+04
+6.404180000000000291e+04
+6.440619999999999709e+04
+6.477340000000000146e+04
+6.514090000000000146e+04
+6.550630000000000291e+04
+6.586750000000000000e+04
+6.622210000000000582e+04
+6.656850000000000000e+04
+6.690489999999999418e+04
+6.722950000000000000e+04
+6.754110000000000582e+04
+6.783810000000000582e+04
+6.811919999999999709e+04
+6.838339999999999418e+04
+6.862939999999999418e+04
+6.885650000000000000e+04
+6.906360000000000582e+04
+6.925010000000000582e+04
+6.941539999999999418e+04
+6.955860000000000582e+04
+6.967950000000000000e+04
+6.977789999999999418e+04
+6.985289999999999418e+04
+6.990460000000000582e+04
+6.993280000000000291e+04
+6.993739999999999418e+04
+6.991810000000000582e+04
+6.987500000000000000e+04
+6.980830000000000291e+04
+6.971800000000000000e+04
+6.960400000000000000e+04
+6.946700000000000000e+04
+6.930680000000000291e+04
+6.912419999999999709e+04
+6.891889999999999418e+04
+6.869180000000000291e+04
+6.844269999999999709e+04
+6.817269999999999709e+04
+6.788180000000000291e+04
+6.757069999999999709e+04
+6.723989999999999418e+04
+6.688939999999999418e+04
+6.652060000000000582e+04
+6.613369999999999709e+04
+6.572930000000000291e+04
+6.530809999999999854e+04
+6.487009999999999854e+04
+6.441669999999999709e+04
+6.394819999999999709e+04
+6.346559999999999854e+04
+6.296880000000000291e+04
+6.245909999999999854e+04
+6.193690000000000146e+04
+6.140259999999999854e+04
+6.085730000000000291e+04
+6.030180000000000291e+04
+5.973659999999999854e+04
+5.916230000000000291e+04
+5.857950000000000000e+04
+5.798890000000000146e+04
+5.739119999999999709e+04
+5.678709999999999854e+04
+5.617690000000000146e+04
+5.556150000000000000e+04
+5.494169999999999709e+04
+5.431830000000000291e+04
+5.369130000000000291e+04
+5.306159999999999854e+04
+5.242990000000000146e+04
+5.179669999999999709e+04
+5.116240000000000146e+04
+5.052769999999999709e+04
+4.989309999999999854e+04
+4.925930000000000291e+04
+4.862690000000000146e+04
+4.799630000000000291e+04
+4.736759999999999854e+04
+4.674150000000000000e+04
+4.611919999999999709e+04
+4.550009999999999854e+04
+4.488480000000000291e+04
+4.427400000000000000e+04
+4.366809999999999854e+04
+4.306759999999999854e+04
+4.247269999999999709e+04
+4.188350000000000000e+04
+4.130080000000000291e+04
+4.072469999999999709e+04
+4.015569999999999709e+04
+3.959400000000000000e+04
+3.903980000000000291e+04
+3.849319999999999709e+04
+3.795500000000000000e+04
+3.742480000000000291e+04
+3.690319999999999709e+04
+3.639040000000000146e+04
+3.588650000000000000e+04
+3.539159999999999854e+04
+3.490609999999999854e+04
+3.442990000000000146e+04
+3.396319999999999709e+04
+3.350630000000000291e+04
+3.305900000000000000e+04
+3.262190000000000146e+04
+3.219470000000000073e+04
+3.177709999999999854e+04
+3.136959999999999854e+04
+3.097240000000000146e+04
+3.058540000000000146e+04
+3.020840000000000146e+04
+2.984150000000000000e+04
+2.948500000000000000e+04
+2.913840000000000146e+04
+2.880190000000000146e+04
+2.847540000000000146e+04
+2.815879999999999927e+04
+2.785290000000000146e+04
+2.755629999999999927e+04
+2.726959999999999854e+04
+2.699270000000000073e+04
+2.672540000000000146e+04
+2.646750000000000000e+04
+2.621929999999999927e+04
+2.598020000000000073e+04
+2.575090000000000146e+04
+2.553020000000000073e+04
+2.531850000000000000e+04
+2.511550000000000000e+04
+2.492140000000000146e+04
+2.473590000000000146e+04
+2.455870000000000073e+04
+2.439000000000000000e+04
+2.422909999999999854e+04
+2.407620000000000073e+04
+2.393109999999999854e+04
+2.379359999999999854e+04
+2.366350000000000000e+04
+2.354070000000000073e+04
+2.342500000000000000e+04
+2.331620000000000073e+04
+2.321400000000000000e+04
+2.311850000000000000e+04
+2.302950000000000000e+04
+2.294659999999999854e+04
+2.286970000000000073e+04
+2.279870000000000073e+04
+2.273359999999999854e+04
+2.267379999999999927e+04
+2.261940000000000146e+04
+2.257000000000000000e+04
+2.252570000000000073e+04
+2.248609999999999854e+04
+2.245129999999999927e+04
+2.242070000000000073e+04
+2.239470000000000073e+04
+2.237279999999999927e+04
+2.235459999999999854e+04
+2.234020000000000073e+04
+2.232950000000000000e+04
+2.232229999999999927e+04
+2.231840000000000146e+04
+2.231770000000000073e+04
+2.231940000000000146e+04
+2.232470000000000073e+04
+2.233240000000000146e+04
+2.234270000000000073e+04
+2.235559999999999854e+04
+2.237070000000000073e+04
+2.238790000000000146e+04
+2.240720000000000073e+04
+2.242840000000000146e+04
+2.245109999999999854e+04
+2.247570000000000073e+04
+2.250159999999999854e+04
+2.252909999999999854e+04
+2.255759999999999854e+04
+2.258729999999999927e+04
+2.261840000000000146e+04
+2.265040000000000146e+04
+2.268309999999999854e+04
+2.271659999999999854e+04
+2.275059999999999854e+04
+2.278529999999999927e+04
+2.282040000000000146e+04
+2.285600000000000000e+04
+2.289200000000000000e+04
+2.292809999999999854e+04
+2.296420000000000073e+04
+2.300029999999999927e+04
+2.303670000000000073e+04
+2.307250000000000000e+04
+2.310870000000000073e+04
+2.314440000000000146e+04
+2.318000000000000000e+04
+2.321500000000000000e+04
+2.324970000000000073e+04
+2.328429999999999927e+04
+2.331809999999999854e+04
+2.335120000000000073e+04
+2.338390000000000146e+04
+2.341579999999999927e+04
+2.344720000000000073e+04
+2.347779999999999927e+04
+2.350759999999999854e+04
+2.353659999999999854e+04
+2.356470000000000073e+04
+2.359170000000000073e+04
+2.361800000000000000e+04
+2.364309999999999854e+04
+2.366759999999999854e+04
+2.369100000000000000e+04
+2.371350000000000000e+04
+2.373479999999999927e+04
+2.375520000000000073e+04
+2.377440000000000146e+04
+2.379259999999999854e+04
+2.380970000000000073e+04
+2.382559999999999854e+04
+2.384079999999999927e+04
+2.385459999999999854e+04
+2.386729999999999927e+04
+2.387879999999999927e+04
+2.388909999999999854e+04
+2.389840000000000146e+04
+2.390640000000000146e+04
+2.391320000000000073e+04
+2.391890000000000146e+04
+2.392329999999999927e+04
+2.392659999999999854e+04
+2.392890000000000146e+04
+2.392950000000000000e+04
+2.392920000000000073e+04
+2.392750000000000000e+04
+2.392500000000000000e+04
+2.392190000000000146e+04
+2.391700000000000000e+04
+2.391109999999999854e+04
+2.390400000000000000e+04
+2.389590000000000146e+04
+2.388650000000000000e+04
+2.387629999999999927e+04
+2.386490000000000146e+04
+2.385229999999999927e+04
+2.383870000000000073e+04
+2.382420000000000073e+04
+2.380859999999999854e+04
+2.379200000000000000e+04
+2.377459999999999854e+04
+2.375590000000000146e+04
+2.373620000000000073e+04
+2.371559999999999854e+04
+2.369429999999999927e+04
+2.367190000000000146e+04
+2.364900000000000000e+04
+2.362470000000000073e+04
+2.359970000000000073e+04
+2.357370000000000073e+04
+2.354670000000000073e+04
+2.351890000000000146e+04
+2.349029999999999927e+04
+2.346079999999999927e+04
+2.343059999999999854e+04
+2.339979999999999927e+04
+2.336800000000000000e+04
+2.333529999999999927e+04
+2.330200000000000000e+04
+2.326790000000000146e+04
+2.323309999999999854e+04
+2.319750000000000000e+04
+2.316120000000000073e+04
+2.312420000000000073e+04
+2.308659999999999854e+04
+2.304820000000000073e+04
+2.300909999999999854e+04
+2.296929999999999927e+04
+2.292900000000000000e+04
+2.288790000000000146e+04
+2.284629999999999927e+04
+2.280390000000000146e+04
+2.276079999999999927e+04
+2.271720000000000073e+04
+2.267300000000000000e+04
+2.262820000000000073e+04
+2.258290000000000146e+04
+2.253679999999999927e+04
+2.249040000000000146e+04
+2.244300000000000000e+04
+2.239509999999999854e+04
+2.234659999999999854e+04
+2.229750000000000000e+04
+2.224800000000000000e+04
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 14870ea..cfe443b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,7 +1,11 @@
 import os
 import pytest
+import numpy as np
+import MDAnalysis as mda
+import shutil
 
 from idpflex import utils
+from idpflex.properties import SaxsProperty, SansProperty
 
 
 def test_write_frame(trajectory_benchmark):
@@ -12,5 +16,21 @@ def test_write_frame(trajectory_benchmark):
     os.remove('test.pdb')
 
 
+@pytest.mark.skipif(shutil.which('cryson') is None
+                    or shutil.which('crysol') is None, reason='Needs cryson')
+def test_generate_trajectory_profiles(saxs_benchmark, sans_benchmark):
+    saxs_ref = np.loadtxt(saxs_benchmark['frame_profile'])
+    sans_ref = np.loadtxt(sans_benchmark['frame_profile'])
+    universe = mda.Universe(saxs_benchmark['crysol_pdb'],
+                            saxs_benchmark['crysol_xtc'])
+    protein = universe.select_atoms('protein')
+    saxs_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SaxsProperty)[3].profile
+    sans_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SansProperty)[3].profile
+    np.testing.assert_array_almost_equal(saxs_ref, saxs_prof)
+    np.testing.assert_array_almost_equal(sans_ref, sans_prof)
+
+
 if __name__ == '__main__':
     pytest.main()

From ba7ee0cfaf48d9f4ad9773372a230ec87e6a3045 Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Tue, 11 Jun 2019 18:16:02 -0400
Subject: [PATCH 2/6] Closes #92 by calculating trajectories for entire
 profiles.

---
 idpflex/properties.py                    |   2 +
 idpflex/utils.py                         |  62 ++-
 tests/conftest.py                        |  10 +-
 tests/data/sans/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/data/saxs/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/test_utils.py                      |  20 +
 6 files changed, 1086 insertions(+), 8 deletions(-)
 create mode 100644 tests/data/sans/trajectory_3_profile.dat
 create mode 100644 tests/data/saxs/trajectory_3_profile.dat

diff --git a/idpflex/properties.py b/idpflex/properties.py
index 129c098..e1d5dce 100644
--- a/idpflex/properties.py
+++ b/idpflex/properties.py
@@ -1372,6 +1372,7 @@ class SansProperty(ProfileProperty, SansLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_cryson_pdb
         if self.name is None:
             self.name = SansProperty.default_name
 
@@ -1510,6 +1511,7 @@ class SaxsProperty(ProfileProperty, SaxsLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_crysol_pdb
         if self.name is None:
             self.name = SaxsProperty.default_name
 
diff --git a/idpflex/utils.py b/idpflex/utils.py
index fb1e54a..10bcbbd 100644
--- a/idpflex/utils.py
+++ b/idpflex/utils.py
@@ -2,33 +2,34 @@
 from contextlib import contextmanager
 import tempfile
 import functools
+import multiprocessing
 from collections import namedtuple, Mapping
 
 import MDAnalysis as mda
 
 
-def write_frame(a_universe, iframe, file_name):
+def write_frame(atom_group, iframe, file_name):
     r"""Write a single trajectory frame to file.
 
     Format is guessed from the file's extension.
 
     Parameters
     ----------
-    a_universe : :class:`~MDAnalysis.core.universe.Universe`
-        Universe describing the simulation
+    atom_group : :class:`~MDAnalysis.AtomGroup`
+        Atoms from the universe describing the simulation
     iframe : int
         Trajectory frame index (indexes begin with zero)
     file_name : str
         Name of the file to create
     """
-    a_universe.trajectory[iframe]
+    atom_group.universe.trajectory[iframe]
     # Create directory if not existing
     dir_name = os.path.dirname(file_name)
     if dir_name and not os.path.isdir(dir_name):
         os.makedirs(dir_name)
 
     with mda.Writer(file_name) as writer:
-        writer.write(a_universe)
+        writer.write(atom_group)
 
 
 @contextmanager
@@ -58,7 +59,7 @@ def namedtuplefy(func):
 
     Parameters
     ----------
-    func: Function
+    func: function
         Function to be decorated
     name: str
         Class name for the namedtuple. If None, the name of the function
@@ -78,3 +79,52 @@ def wrapper(*args, **kwargs):
         return wrapper.nt(**res)
     wrapper.nt = None
     return wrapper
+
+
+def generate_profile_for_frame(atom_group, iframe, profile_class):
+    r"""
+    Utility function to generate profile properties for a frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframe: int
+        The index of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    Profile for the selected frame
+    """  # noqa: E501
+    with temporary_file(suffix='.pdb') as fname:
+        # Copy the atom group to a new universe to avoid
+        # changing frames upon writing
+        u = atom_group.universe
+        u2 = mda.Universe(u.filename, u.trajectory.filename)
+        atoms2 = u2.atoms[atom_group.atoms.indices]
+        write_frame(atoms2, iframe, fname)
+        return profile_class().from_pdb(fname)
+
+
+def generate_trajectory_profiles(atom_group, iframes, profile_class):
+    r"""
+    Utility function to generate profile properties for each frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframes: List[int]
+        The indices of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    List of the profiles.
+    """  # noqa: E501
+    with multiprocessing.Pool() as p:
+        return p.starmap(generate_profile_for_frame,
+                         [(atom_group, i, profile_class) for i in iframes])
diff --git a/tests/conftest.py b/tests/conftest.py
index 3f42d90..9d58f5b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -106,14 +106,17 @@ def saxs_benchmark():
         'crysol_pdb': absolute path to file.
         'crysol_int': absolute path to file.
         'crysol_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     crysol_file = os.path.join(data_dir, 'saxs', 'crysol.dat')
     crysol_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     crysol_int = os.path.join(data_dir, 'saxs', 'md_0_100.int')
     crysol_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'saxs', 'trajectory_3_profile.dat')
     return dict(crysol_file=crysol_file, crysol_pdb=crysol_pdb,
-                crysol_int=crysol_int, crysol_xtc=crysol_xtc)
+                crysol_int=crysol_int, crysol_xtc=crysol_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
@@ -130,6 +133,7 @@ def sans_benchmark(request):
         'cryson_pdb': absolute path to file.
         'cryson_int': absolute path to file.
         'cryson_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     # setup or initialization
@@ -153,13 +157,15 @@ def sans_benchmark(request):
     cryson_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     cryson_int = os.path.join(data_dir, 'sans', 'md_0_100.int')
     cryson_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'sans', 'trajectory_3_profile.dat')
 
     def teardown():
         handle.close()
     request.addfinalizer(teardown)
     return dict(profiles=handle, property_list=values,
                 tree_with_no_property=tree, cryson_pdb=cryson_pdb,
-                cryson_int=cryson_int, cryson_xtc=cryson_xtc)
+                cryson_int=cryson_int, cryson_xtc=cryson_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
diff --git a/tests/data/sans/trajectory_3_profile.dat b/tests/data/sans/trajectory_3_profile.dat
new file mode 100644
index 0000000..d4af149
--- /dev/null
+++ b/tests/data/sans/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+5.802240000000000000e+05
+5.801650000000000000e+05
+5.800010000000000000e+05
+5.797260000000000000e+05
+5.793430000000000000e+05
+5.788500000000000000e+05
+5.782480000000000000e+05
+5.775380000000000000e+05
+5.767190000000000000e+05
+5.757930000000000000e+05
+5.747590000000000000e+05
+5.736180000000000000e+05
+5.723720000000000000e+05
+5.710190000000000000e+05
+5.695630000000000000e+05
+5.680020000000000000e+05
+5.663380000000000000e+05
+5.645710000000000000e+05
+5.627040000000000000e+05
+5.607360000000000000e+05
+5.586690000000000000e+05
+5.565050000000000000e+05
+5.542430000000000000e+05
+5.518850000000000000e+05
+5.494330000000000000e+05
+5.468880000000000000e+05
+5.442510000000000000e+05
+5.415230000000000000e+05
+5.387060000000000000e+05
+5.358020000000000000e+05
+5.328110000000000000e+05
+5.297360000000000000e+05
+5.265780000000000000e+05
+5.233390000000000000e+05
+5.200210000000000000e+05
+5.166240000000000000e+05
+5.131510000000000000e+05
+5.096030000000000000e+05
+5.059830000000000000e+05
+5.022920000000000000e+05
+4.985320000000000000e+05
+4.947050000000000000e+05
+4.908130000000000000e+05
+4.868570000000000000e+05
+4.828400000000000000e+05
+4.787640000000000000e+05
+4.746300000000000000e+05
+4.704400000000000000e+05
+4.661980000000000000e+05
+4.619030000000000000e+05
+4.575600000000000000e+05
+4.531690000000000000e+05
+4.487330000000000000e+05
+4.442530000000000000e+05
+4.397330000000000000e+05
+4.351730000000000000e+05
+4.305760000000000000e+05
+4.259450000000000000e+05
+4.212800000000000000e+05
+4.165850000000000000e+05
+4.118610000000000000e+05
+4.071100000000000000e+05
+4.023350000000000000e+05
+3.975370000000000000e+05
+3.927190000000000000e+05
+3.878820000000000000e+05
+3.830290000000000000e+05
+3.781610000000000000e+05
+3.732810000000000000e+05
+3.683900000000000000e+05
+3.634910000000000000e+05
+3.585860000000000000e+05
+3.536750000000000000e+05
+3.487620000000000000e+05
+3.438480000000000000e+05
+3.389350000000000000e+05
+3.340250000000000000e+05
+3.291190000000000000e+05
+3.242200000000000000e+05
+3.193290000000000000e+05
+3.144480000000000000e+05
+3.095790000000000000e+05
+3.047220000000000000e+05
+2.998810000000000000e+05
+2.950570000000000000e+05
+2.902500000000000000e+05
+2.854630000000000000e+05
+2.806970000000000000e+05
+2.759540000000000000e+05
+2.712350000000000000e+05
+2.665420000000000000e+05
+2.618750000000000000e+05
+2.572370000000000000e+05
+2.526280000000000000e+05
+2.480500000000000000e+05
+2.435050000000000000e+05
+2.389920000000000000e+05
+2.345140000000000000e+05
+2.300710000000000000e+05
+2.256650000000000000e+05
+2.212960000000000000e+05
+2.169660000000000000e+05
+2.126760000000000000e+05
+2.084260000000000000e+05
+2.042180000000000000e+05
+2.000520000000000000e+05
+1.959290000000000000e+05
+1.918490000000000000e+05
+1.878150000000000000e+05
+1.838250000000000000e+05
+1.798820000000000000e+05
+1.759850000000000000e+05
+1.721350000000000000e+05
+1.683330000000000000e+05
+1.645790000000000000e+05
+1.608740000000000000e+05
+1.572180000000000000e+05
+1.536110000000000000e+05
+1.500540000000000000e+05
+1.465480000000000000e+05
+1.430910000000000000e+05
+1.396860000000000000e+05
+1.363310000000000000e+05
+1.330280000000000000e+05
+1.297760000000000000e+05
+1.265750000000000000e+05
+1.234260000000000000e+05
+1.203280000000000000e+05
+1.172820000000000000e+05
+1.142870000000000000e+05
+1.113450000000000000e+05
+1.084530000000000000e+05
+1.056130000000000000e+05
+1.028250000000000000e+05
+1.000870000000000000e+05
+9.740100000000000000e+04
+9.476550000000000000e+04
+9.218060000000000582e+04
+8.964610000000000582e+04
+8.716169999999999709e+04
+8.472719999999999709e+04
+8.234219999999999709e+04
+8.000639999999999418e+04
+7.771950000000000000e+04
+7.548110000000000582e+04
+7.329080000000000291e+04
+7.114819999999999709e+04
+6.905289999999999418e+04
+6.700450000000000000e+04
+6.500250000000000000e+04
+6.304640000000000146e+04
+6.113580000000000291e+04
+5.927019999999999709e+04
+5.744900000000000000e+04
+5.567180000000000291e+04
+5.393800000000000000e+04
+5.224709999999999854e+04
+5.059840000000000146e+04
+4.899159999999999854e+04
+4.742590000000000146e+04
+4.590080000000000291e+04
+4.441580000000000291e+04
+4.297009999999999854e+04
+4.156330000000000291e+04
+4.019469999999999709e+04
+3.886369999999999709e+04
+3.756980000000000291e+04
+3.631219999999999709e+04
+3.509030000000000291e+04
+3.390359999999999854e+04
+3.275140000000000146e+04
+3.163309999999999854e+04
+3.054800000000000000e+04
+2.949550000000000000e+04
+2.847500000000000000e+04
+2.748590000000000146e+04
+2.652750000000000000e+04
+2.559920000000000073e+04
+2.470040000000000146e+04
+2.383040000000000146e+04
+2.298870000000000073e+04
+2.217459999999999854e+04
+2.138740000000000146e+04
+2.062670000000000073e+04
+1.989170000000000073e+04
+1.918190000000000146e+04
+1.849670000000000073e+04
+1.783540000000000146e+04
+1.719750000000000000e+04
+1.658250000000000000e+04
+1.598960000000000036e+04
+1.541839999999999964e+04
+1.486829999999999927e+04
+1.433879999999999927e+04
+1.382920000000000073e+04
+1.333900000000000000e+04
+1.286779999999999927e+04
+1.241489999999999964e+04
+1.197989999999999964e+04
+1.156210000000000036e+04
+1.116120000000000073e+04
+1.077660000000000036e+04
+1.040789999999999964e+04
+1.005439999999999964e+04
+9.715879999999999200e+03
+9.391700000000000728e+03
+9.081459999999999127e+03
+8.784700000000000728e+03
+8.500969999999999345e+03
+8.229850000000000364e+03
+7.970909999999999854e+03
+7.723729999999999563e+03
+7.487890000000000327e+03
+7.263000000000000000e+03
+7.048659999999999854e+03
+6.844489999999999782e+03
+6.650119999999999891e+03
+6.465170000000000073e+03
+6.289300000000000182e+03
+6.122140000000000327e+03
+5.963359999999999673e+03
+5.812619999999999891e+03
+5.669590000000000146e+03
+5.533970000000000255e+03
+5.405439999999999600e+03
+5.283699999999999818e+03
+5.168449999999999818e+03
+5.059409999999999854e+03
+4.956319999999999709e+03
+4.858880000000000109e+03
+4.766840000000000146e+03
+4.679949999999999818e+03
+4.597960000000000036e+03
+4.520630000000000109e+03
+4.447729999999999563e+03
+4.379050000000000182e+03
+4.314340000000000146e+03
+4.253409999999999854e+03
+4.196050000000000182e+03
+4.142060000000000400e+03
+4.091250000000000000e+03
+4.043440000000000055e+03
+3.998449999999999818e+03
+3.956110000000000127e+03
+3.916250000000000000e+03
+3.878719999999999800e+03
+3.843349999999999909e+03
+3.810019999999999982e+03
+3.778550000000000182e+03
+3.748829999999999927e+03
+3.720719999999999800e+03
+3.694090000000000146e+03
+3.668820000000000164e+03
+3.644820000000000164e+03
+3.621940000000000055e+03
+3.600110000000000127e+03
+3.579210000000000036e+03
+3.559150000000000091e+03
+3.539820000000000164e+03
+3.521159999999999854e+03
+3.503079999999999927e+03
+3.485500000000000000e+03
+3.468329999999999927e+03
+3.451519999999999982e+03
+3.434989999999999782e+03
+3.418679999999999836e+03
+3.402539999999999964e+03
+3.386500000000000000e+03
+3.370519999999999982e+03
+3.354539999999999964e+03
+3.338510000000000218e+03
+3.322409999999999854e+03
+3.306179999999999836e+03
+3.289800000000000182e+03
+3.273210000000000036e+03
+3.256400000000000091e+03
+3.239340000000000146e+03
+3.221989999999999782e+03
+3.204349999999999909e+03
+3.186369999999999891e+03
+3.168050000000000182e+03
+3.149380000000000109e+03
+3.130309999999999945e+03
+3.110860000000000127e+03
+3.091010000000000218e+03
+3.070760000000000218e+03
+3.050099999999999909e+03
+3.029010000000000218e+03
+3.007500000000000000e+03
+2.985559999999999945e+03
+2.963190000000000055e+03
+2.940409999999999854e+03
+2.917190000000000055e+03
+2.893559999999999945e+03
+2.869519999999999982e+03
+2.845059999999999945e+03
+2.820210000000000036e+03
+2.794969999999999800e+03
+2.769340000000000146e+03
+2.743340000000000146e+03
+2.716969999999999800e+03
+2.690239999999999782e+03
+2.663190000000000055e+03
+2.635820000000000164e+03
+2.608130000000000109e+03
+2.580150000000000091e+03
+2.551889999999999873e+03
+2.523349999999999909e+03
+2.494579999999999927e+03
+2.465559999999999945e+03
+2.436340000000000146e+03
+2.406909999999999854e+03
+2.377300000000000182e+03
+2.347519999999999982e+03
+2.317599999999999909e+03
+2.287550000000000182e+03
+2.257380000000000109e+03
+2.227119999999999891e+03
+2.196789999999999964e+03
+2.166409999999999854e+03
+2.135989999999999782e+03
+2.105550000000000182e+03
+2.075110000000000127e+03
+2.044690000000000055e+03
+2.014289999999999964e+03
+1.983960000000000036e+03
+1.953710000000000036e+03
+1.923529999999999973e+03
+1.893460000000000036e+03
+1.863509999999999991e+03
+1.833710000000000036e+03
+1.804049999999999955e+03
+1.774569999999999936e+03
+1.745259999999999991e+03
+1.716180000000000064e+03
+1.687299999999999955e+03
+1.658650000000000091e+03
+1.630250000000000000e+03
+1.602109999999999900e+03
+1.574250000000000000e+03
+1.546670000000000073e+03
+1.519390000000000100e+03
+1.492440000000000055e+03
+1.465799999999999955e+03
+1.439490000000000009e+03
+1.413519999999999982e+03
+1.387910000000000082e+03
+1.362670000000000073e+03
+1.337799999999999955e+03
+1.313309999999999945e+03
+1.289220000000000027e+03
+1.265529999999999973e+03
+1.242240000000000009e+03
+1.219359999999999900e+03
+1.196900000000000091e+03
+1.174880000000000109e+03
+1.153279999999999973e+03
+1.132109999999999900e+03
+1.111380000000000109e+03
+1.091099999999999909e+03
+1.071259999999999991e+03
+1.051869999999999891e+03
+1.032940000000000055e+03
+1.014460000000000036e+03
+9.964370000000000118e+02
+9.788659999999999854e+02
+9.617509999999999764e+02
+9.450940000000000509e+02
+9.288959999999999582e+02
+9.131539999999999964e+02
+8.978579999999999472e+02
+8.830199999999999818e+02
+8.686309999999999718e+02
+8.546960000000000264e+02
+8.412010000000000218e+02
+8.281559999999999491e+02
+8.155470000000000255e+02
+8.033750000000000000e+02
+7.916319999999999482e+02
+7.803170000000000073e+02
+7.694260000000000446e+02
+7.589539999999999509e+02
+7.488949999999999818e+02
+7.392390000000000327e+02
+7.299819999999999709e+02
+7.211159999999999854e+02
+7.126430000000000291e+02
+7.045470000000000255e+02
+6.968310000000000173e+02
+6.894800000000000182e+02
+6.824900000000000091e+02
+6.758569999999999709e+02
+6.695539999999999736e+02
+6.636000000000000227e+02
+6.579759999999999991e+02
+6.526710000000000491e+02
+6.476839999999999691e+02
+6.430069999999999482e+02
+6.386230000000000473e+02
+6.345380000000000109e+02
+6.307219999999999800e+02
+6.271839999999999691e+02
+6.239109999999999445e+02
+6.208949999999999818e+02
+6.181130000000000564e+02
+6.155750000000000455e+02
+6.132609999999999673e+02
+6.111749999999999545e+02
+6.093049999999999500e+02
+6.076230000000000473e+02
+6.061449999999999818e+02
+6.048609999999999900e+02
+6.037649999999999864e+02
+6.028260000000000218e+02
+6.020579999999999927e+02
+6.014349999999999454e+02
+6.009569999999999936e+02
+6.006299999999999955e+02
+6.004329999999999927e+02
+6.003479999999999563e+02
+6.003840000000000146e+02
+6.005249999999999773e+02
+6.007680000000000291e+02
+6.011040000000000418e+02
+6.015270000000000437e+02
+6.020240000000000009e+02
+6.025940000000000509e+02
+6.032309999999999945e+02
+6.039210000000000491e+02
+6.046649999999999636e+02
+6.054539999999999509e+02
+6.062899999999999636e+02
+6.071589999999999918e+02
+6.080460000000000491e+02
+6.089679999999999609e+02
+6.099109999999999445e+02
+6.108600000000000136e+02
+6.118160000000000309e+02
+6.127690000000000055e+02
+6.137329999999999472e+02
+6.146860000000000355e+02
+6.156290000000000191e+02
+6.165549999999999500e+02
+6.174610000000000127e+02
+6.183410000000000082e+02
+6.192000000000000455e+02
+6.200349999999999682e+02
+6.208339999999999463e+02
+6.216090000000000373e+02
+6.223390000000000555e+02
+6.230399999999999636e+02
+6.236839999999999691e+02
+6.242839999999999918e+02
+6.248379999999999654e+02
+6.253460000000000036e+02
+6.258070000000000164e+02
+6.262100000000000364e+02
+6.265629999999999882e+02
+6.268690000000000282e+02
+6.271159999999999854e+02
+6.273060000000000400e+02
+6.274339999999999691e+02
+6.275090000000000146e+02
+6.275199999999999818e+02
+6.274750000000000227e+02
+6.273640000000000327e+02
+6.272019999999999982e+02
+6.269859999999999900e+02
+6.267129999999999654e+02
+6.263740000000000236e+02
+6.259829999999999472e+02
+6.255389999999999873e+02
+6.250420000000000300e+02
+6.244900000000000091e+02
+6.238790000000000191e+02
+6.232110000000000127e+02
+6.224919999999999618e+02
+6.217190000000000509e+02
+6.209020000000000437e+02
+6.200330000000000155e+02
+6.191109999999999900e+02
+6.181499999999999773e+02
+6.171359999999999673e+02
+6.160839999999999463e+02
+6.149829999999999472e+02
+6.138429999999999609e+02
+6.126649999999999636e+02
+6.114560000000000173e+02
+6.102129999999999654e+02
+6.089270000000000209e+02
+6.076250000000000000e+02
+6.062740000000000009e+02
+6.049009999999999536e+02
+6.035019999999999527e+02
+6.020819999999999936e+02
+6.006319999999999482e+02
+5.991689999999999827e+02
+5.976789999999999736e+02
+5.961749999999999545e+02
+5.946499999999999773e+02
diff --git a/tests/data/saxs/trajectory_3_profile.dat b/tests/data/saxs/trajectory_3_profile.dat
new file mode 100644
index 0000000..effca13
--- /dev/null
+++ b/tests/data/saxs/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+8.128970000000000000e+06
+8.127820000000000000e+06
+8.124460000000000000e+06
+8.118860000000000000e+06
+8.111030000000000000e+06
+8.100960000000000000e+06
+8.088680000000000000e+06
+8.074190000000000000e+06
+8.057500000000000000e+06
+8.038620000000000000e+06
+8.017570000000000000e+06
+7.994370000000000000e+06
+7.969010000000000000e+06
+7.941560000000000000e+06
+7.912050000000000000e+06
+7.880380000000000000e+06
+7.846770000000000000e+06
+7.811090000000000000e+06
+7.773290000000000000e+06
+7.733740000000000000e+06
+7.692170000000000000e+06
+7.648590000000000000e+06
+7.603150000000000000e+06
+7.555830000000000000e+06
+7.506850000000000000e+06
+7.455980000000000000e+06
+7.403430000000000000e+06
+7.349180000000000000e+06
+7.293250000000000000e+06
+7.235750000000000000e+06
+7.176640000000000000e+06
+7.116040000000000000e+06
+7.053900000000000000e+06
+6.990350000000000000e+06
+6.925400000000000000e+06
+6.859120000000000000e+06
+6.791510000000000000e+06
+6.722650000000000000e+06
+6.652600000000000000e+06
+6.581370000000000000e+06
+6.509050000000000000e+06
+6.435670000000000000e+06
+6.361270000000000000e+06
+6.285910000000000000e+06
+6.209630000000000000e+06
+6.132510000000000000e+06
+6.054570000000000000e+06
+5.975880000000000000e+06
+5.896470000000000000e+06
+5.816410000000000000e+06
+5.735750000000000000e+06
+5.654530000000000000e+06
+5.572820000000000000e+06
+5.490650000000000000e+06
+5.408070000000000000e+06
+5.325140000000000000e+06
+5.241910000000000000e+06
+5.158420000000000000e+06
+5.074740000000000000e+06
+4.990890000000000000e+06
+4.906940000000000000e+06
+4.822920000000000000e+06
+4.738890000000000000e+06
+4.654890000000000000e+06
+4.570970000000000000e+06
+4.487180000000000000e+06
+4.403540000000000000e+06
+4.320120000000000000e+06
+4.236940000000000000e+06
+4.154060000000000000e+06
+4.071520000000000000e+06
+3.989340000000000000e+06
+3.907580000000000000e+06
+3.826270000000000000e+06
+3.745440000000000000e+06
+3.665130000000000000e+06
+3.585390000000000000e+06
+3.506230000000000000e+06
+3.427700000000000000e+06
+3.349820000000000000e+06
+3.272630000000000000e+06
+3.196160000000000000e+06
+3.120430000000000000e+06
+3.045470000000000000e+06
+2.971310000000000000e+06
+2.897970000000000000e+06
+2.825480000000000000e+06
+2.753850000000000000e+06
+2.683120000000000000e+06
+2.613300000000000000e+06
+2.544400000000000000e+06
+2.476460000000000000e+06
+2.409480000000000000e+06
+2.343480000000000000e+06
+2.278480000000000000e+06
+2.214490000000000000e+06
+2.151520000000000000e+06
+2.089580000000000000e+06
+2.028690000000000000e+06
+1.968840000000000000e+06
+1.910060000000000000e+06
+1.852350000000000000e+06
+1.795710000000000000e+06
+1.740150000000000000e+06
+1.685680000000000000e+06
+1.632290000000000000e+06
+1.579980000000000000e+06
+1.528770000000000000e+06
+1.478650000000000000e+06
+1.429610000000000000e+06
+1.381670000000000000e+06
+1.334800000000000000e+06
+1.289020000000000000e+06
+1.244320000000000000e+06
+1.200690000000000000e+06
+1.158130000000000000e+06
+1.116630000000000000e+06
+1.076180000000000000e+06
+1.036770000000000000e+06
+9.984100000000000000e+05
+9.610740000000000000e+05
+9.247570000000000000e+05
+8.894490000000000000e+05
+8.551380000000000000e+05
+8.218150000000000000e+05
+7.894660000000000000e+05
+7.580790000000000000e+05
+7.276430000000000000e+05
+6.981430000000000000e+05
+6.695670000000000000e+05
+6.419000000000000000e+05
+6.151280000000000000e+05
+5.892370000000000000e+05
+5.642120000000000000e+05
+5.400370000000000000e+05
+5.166980000000000000e+05
+4.941770000000000000e+05
+4.724610000000000000e+05
+4.515330000000000000e+05
+4.313770000000000000e+05
+4.119760000000000000e+05
+3.933140000000000000e+05
+3.753750000000000000e+05
+3.581430000000000000e+05
+3.416000000000000000e+05
+3.257310000000000000e+05
+3.105180000000000000e+05
+2.959450000000000000e+05
+2.819960000000000000e+05
+2.686530000000000000e+05
+2.559010000000000000e+05
+2.437240000000000000e+05
+2.321050000000000000e+05
+2.210270000000000000e+05
+2.104750000000000000e+05
+2.004340000000000000e+05
+1.908870000000000000e+05
+1.818180000000000000e+05
+1.732120000000000000e+05
+1.650550000000000000e+05
+1.573310000000000000e+05
+1.500240000000000000e+05
+1.431220000000000000e+05
+1.366090000000000000e+05
+1.304700000000000000e+05
+1.246940000000000000e+05
+1.192640000000000000e+05
+1.141680000000000000e+05
+1.093940000000000000e+05
+1.049270000000000000e+05
+1.007560000000000000e+05
+9.686700000000000000e+04
+9.324910000000000582e+04
+8.989030000000000291e+04
+8.677860000000000582e+04
+8.390319999999999709e+04
+8.125269999999999709e+04
+7.881660000000000582e+04
+7.658430000000000291e+04
+7.454569999999999709e+04
+7.269089999999999418e+04
+7.101030000000000291e+04
+6.949450000000000000e+04
+6.813450000000000000e+04
+6.692150000000000000e+04
+6.584710000000000582e+04
+6.490269999999999709e+04
+6.408100000000000000e+04
+6.337380000000000291e+04
+6.277369999999999709e+04
+6.227380000000000291e+04
+6.186709999999999854e+04
+6.154690000000000146e+04
+6.130669999999999709e+04
+6.114059999999999854e+04
+6.104240000000000146e+04
+6.100659999999999854e+04
+6.102759999999999854e+04
+6.110040000000000146e+04
+6.122000000000000000e+04
+6.138140000000000146e+04
+6.158030000000000291e+04
+6.181230000000000291e+04
+6.207340000000000146e+04
+6.235980000000000291e+04
+6.266700000000000000e+04
+6.299240000000000146e+04
+6.333200000000000000e+04
+6.368290000000000146e+04
+6.404180000000000291e+04
+6.440619999999999709e+04
+6.477340000000000146e+04
+6.514090000000000146e+04
+6.550630000000000291e+04
+6.586750000000000000e+04
+6.622210000000000582e+04
+6.656850000000000000e+04
+6.690489999999999418e+04
+6.722950000000000000e+04
+6.754110000000000582e+04
+6.783810000000000582e+04
+6.811919999999999709e+04
+6.838339999999999418e+04
+6.862939999999999418e+04
+6.885650000000000000e+04
+6.906360000000000582e+04
+6.925010000000000582e+04
+6.941539999999999418e+04
+6.955860000000000582e+04
+6.967950000000000000e+04
+6.977789999999999418e+04
+6.985289999999999418e+04
+6.990460000000000582e+04
+6.993280000000000291e+04
+6.993739999999999418e+04
+6.991810000000000582e+04
+6.987500000000000000e+04
+6.980830000000000291e+04
+6.971800000000000000e+04
+6.960400000000000000e+04
+6.946700000000000000e+04
+6.930680000000000291e+04
+6.912419999999999709e+04
+6.891889999999999418e+04
+6.869180000000000291e+04
+6.844269999999999709e+04
+6.817269999999999709e+04
+6.788180000000000291e+04
+6.757069999999999709e+04
+6.723989999999999418e+04
+6.688939999999999418e+04
+6.652060000000000582e+04
+6.613369999999999709e+04
+6.572930000000000291e+04
+6.530809999999999854e+04
+6.487009999999999854e+04
+6.441669999999999709e+04
+6.394819999999999709e+04
+6.346559999999999854e+04
+6.296880000000000291e+04
+6.245909999999999854e+04
+6.193690000000000146e+04
+6.140259999999999854e+04
+6.085730000000000291e+04
+6.030180000000000291e+04
+5.973659999999999854e+04
+5.916230000000000291e+04
+5.857950000000000000e+04
+5.798890000000000146e+04
+5.739119999999999709e+04
+5.678709999999999854e+04
+5.617690000000000146e+04
+5.556150000000000000e+04
+5.494169999999999709e+04
+5.431830000000000291e+04
+5.369130000000000291e+04
+5.306159999999999854e+04
+5.242990000000000146e+04
+5.179669999999999709e+04
+5.116240000000000146e+04
+5.052769999999999709e+04
+4.989309999999999854e+04
+4.925930000000000291e+04
+4.862690000000000146e+04
+4.799630000000000291e+04
+4.736759999999999854e+04
+4.674150000000000000e+04
+4.611919999999999709e+04
+4.550009999999999854e+04
+4.488480000000000291e+04
+4.427400000000000000e+04
+4.366809999999999854e+04
+4.306759999999999854e+04
+4.247269999999999709e+04
+4.188350000000000000e+04
+4.130080000000000291e+04
+4.072469999999999709e+04
+4.015569999999999709e+04
+3.959400000000000000e+04
+3.903980000000000291e+04
+3.849319999999999709e+04
+3.795500000000000000e+04
+3.742480000000000291e+04
+3.690319999999999709e+04
+3.639040000000000146e+04
+3.588650000000000000e+04
+3.539159999999999854e+04
+3.490609999999999854e+04
+3.442990000000000146e+04
+3.396319999999999709e+04
+3.350630000000000291e+04
+3.305900000000000000e+04
+3.262190000000000146e+04
+3.219470000000000073e+04
+3.177709999999999854e+04
+3.136959999999999854e+04
+3.097240000000000146e+04
+3.058540000000000146e+04
+3.020840000000000146e+04
+2.984150000000000000e+04
+2.948500000000000000e+04
+2.913840000000000146e+04
+2.880190000000000146e+04
+2.847540000000000146e+04
+2.815879999999999927e+04
+2.785290000000000146e+04
+2.755629999999999927e+04
+2.726959999999999854e+04
+2.699270000000000073e+04
+2.672540000000000146e+04
+2.646750000000000000e+04
+2.621929999999999927e+04
+2.598020000000000073e+04
+2.575090000000000146e+04
+2.553020000000000073e+04
+2.531850000000000000e+04
+2.511550000000000000e+04
+2.492140000000000146e+04
+2.473590000000000146e+04
+2.455870000000000073e+04
+2.439000000000000000e+04
+2.422909999999999854e+04
+2.407620000000000073e+04
+2.393109999999999854e+04
+2.379359999999999854e+04
+2.366350000000000000e+04
+2.354070000000000073e+04
+2.342500000000000000e+04
+2.331620000000000073e+04
+2.321400000000000000e+04
+2.311850000000000000e+04
+2.302950000000000000e+04
+2.294659999999999854e+04
+2.286970000000000073e+04
+2.279870000000000073e+04
+2.273359999999999854e+04
+2.267379999999999927e+04
+2.261940000000000146e+04
+2.257000000000000000e+04
+2.252570000000000073e+04
+2.248609999999999854e+04
+2.245129999999999927e+04
+2.242070000000000073e+04
+2.239470000000000073e+04
+2.237279999999999927e+04
+2.235459999999999854e+04
+2.234020000000000073e+04
+2.232950000000000000e+04
+2.232229999999999927e+04
+2.231840000000000146e+04
+2.231770000000000073e+04
+2.231940000000000146e+04
+2.232470000000000073e+04
+2.233240000000000146e+04
+2.234270000000000073e+04
+2.235559999999999854e+04
+2.237070000000000073e+04
+2.238790000000000146e+04
+2.240720000000000073e+04
+2.242840000000000146e+04
+2.245109999999999854e+04
+2.247570000000000073e+04
+2.250159999999999854e+04
+2.252909999999999854e+04
+2.255759999999999854e+04
+2.258729999999999927e+04
+2.261840000000000146e+04
+2.265040000000000146e+04
+2.268309999999999854e+04
+2.271659999999999854e+04
+2.275059999999999854e+04
+2.278529999999999927e+04
+2.282040000000000146e+04
+2.285600000000000000e+04
+2.289200000000000000e+04
+2.292809999999999854e+04
+2.296420000000000073e+04
+2.300029999999999927e+04
+2.303670000000000073e+04
+2.307250000000000000e+04
+2.310870000000000073e+04
+2.314440000000000146e+04
+2.318000000000000000e+04
+2.321500000000000000e+04
+2.324970000000000073e+04
+2.328429999999999927e+04
+2.331809999999999854e+04
+2.335120000000000073e+04
+2.338390000000000146e+04
+2.341579999999999927e+04
+2.344720000000000073e+04
+2.347779999999999927e+04
+2.350759999999999854e+04
+2.353659999999999854e+04
+2.356470000000000073e+04
+2.359170000000000073e+04
+2.361800000000000000e+04
+2.364309999999999854e+04
+2.366759999999999854e+04
+2.369100000000000000e+04
+2.371350000000000000e+04
+2.373479999999999927e+04
+2.375520000000000073e+04
+2.377440000000000146e+04
+2.379259999999999854e+04
+2.380970000000000073e+04
+2.382559999999999854e+04
+2.384079999999999927e+04
+2.385459999999999854e+04
+2.386729999999999927e+04
+2.387879999999999927e+04
+2.388909999999999854e+04
+2.389840000000000146e+04
+2.390640000000000146e+04
+2.391320000000000073e+04
+2.391890000000000146e+04
+2.392329999999999927e+04
+2.392659999999999854e+04
+2.392890000000000146e+04
+2.392950000000000000e+04
+2.392920000000000073e+04
+2.392750000000000000e+04
+2.392500000000000000e+04
+2.392190000000000146e+04
+2.391700000000000000e+04
+2.391109999999999854e+04
+2.390400000000000000e+04
+2.389590000000000146e+04
+2.388650000000000000e+04
+2.387629999999999927e+04
+2.386490000000000146e+04
+2.385229999999999927e+04
+2.383870000000000073e+04
+2.382420000000000073e+04
+2.380859999999999854e+04
+2.379200000000000000e+04
+2.377459999999999854e+04
+2.375590000000000146e+04
+2.373620000000000073e+04
+2.371559999999999854e+04
+2.369429999999999927e+04
+2.367190000000000146e+04
+2.364900000000000000e+04
+2.362470000000000073e+04
+2.359970000000000073e+04
+2.357370000000000073e+04
+2.354670000000000073e+04
+2.351890000000000146e+04
+2.349029999999999927e+04
+2.346079999999999927e+04
+2.343059999999999854e+04
+2.339979999999999927e+04
+2.336800000000000000e+04
+2.333529999999999927e+04
+2.330200000000000000e+04
+2.326790000000000146e+04
+2.323309999999999854e+04
+2.319750000000000000e+04
+2.316120000000000073e+04
+2.312420000000000073e+04
+2.308659999999999854e+04
+2.304820000000000073e+04
+2.300909999999999854e+04
+2.296929999999999927e+04
+2.292900000000000000e+04
+2.288790000000000146e+04
+2.284629999999999927e+04
+2.280390000000000146e+04
+2.276079999999999927e+04
+2.271720000000000073e+04
+2.267300000000000000e+04
+2.262820000000000073e+04
+2.258290000000000146e+04
+2.253679999999999927e+04
+2.249040000000000146e+04
+2.244300000000000000e+04
+2.239509999999999854e+04
+2.234659999999999854e+04
+2.229750000000000000e+04
+2.224800000000000000e+04
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 14870ea..cfe443b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,7 +1,11 @@
 import os
 import pytest
+import numpy as np
+import MDAnalysis as mda
+import shutil
 
 from idpflex import utils
+from idpflex.properties import SaxsProperty, SansProperty
 
 
 def test_write_frame(trajectory_benchmark):
@@ -12,5 +16,21 @@ def test_write_frame(trajectory_benchmark):
     os.remove('test.pdb')
 
 
+@pytest.mark.skipif(shutil.which('cryson') is None
+                    or shutil.which('crysol') is None, reason='Needs cryson')
+def test_generate_trajectory_profiles(saxs_benchmark, sans_benchmark):
+    saxs_ref = np.loadtxt(saxs_benchmark['frame_profile'])
+    sans_ref = np.loadtxt(sans_benchmark['frame_profile'])
+    universe = mda.Universe(saxs_benchmark['crysol_pdb'],
+                            saxs_benchmark['crysol_xtc'])
+    protein = universe.select_atoms('protein')
+    saxs_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SaxsProperty)[3].profile
+    sans_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SansProperty)[3].profile
+    np.testing.assert_array_almost_equal(saxs_ref, saxs_prof)
+    np.testing.assert_array_almost_equal(sans_ref, sans_prof)
+
+
 if __name__ == '__main__':
     pytest.main()

From a9dacbe0cbc1059d7ee18b6462ee70835a27da97 Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Tue, 11 Jun 2019 18:16:02 -0400
Subject: [PATCH 3/6] Closes #92 by calculating trajectories for entire
 profiles.

---
 idpflex/properties.py                    |   2 +
 idpflex/utils.py                         |  62 ++-
 tests/conftest.py                        |  10 +-
 tests/data/sans/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/data/saxs/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/test_utils.py                      |  20 +
 6 files changed, 1086 insertions(+), 8 deletions(-)
 create mode 100644 tests/data/sans/trajectory_3_profile.dat
 create mode 100644 tests/data/saxs/trajectory_3_profile.dat

diff --git a/idpflex/properties.py b/idpflex/properties.py
index 129c098..e1d5dce 100644
--- a/idpflex/properties.py
+++ b/idpflex/properties.py
@@ -1372,6 +1372,7 @@ class SansProperty(ProfileProperty, SansLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_cryson_pdb
         if self.name is None:
             self.name = SansProperty.default_name
 
@@ -1510,6 +1511,7 @@ class SaxsProperty(ProfileProperty, SaxsLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_crysol_pdb
         if self.name is None:
             self.name = SaxsProperty.default_name
 
diff --git a/idpflex/utils.py b/idpflex/utils.py
index fb1e54a..10bcbbd 100644
--- a/idpflex/utils.py
+++ b/idpflex/utils.py
@@ -2,33 +2,34 @@
 from contextlib import contextmanager
 import tempfile
 import functools
+import multiprocessing
 from collections import namedtuple, Mapping
 
 import MDAnalysis as mda
 
 
-def write_frame(a_universe, iframe, file_name):
+def write_frame(atom_group, iframe, file_name):
     r"""Write a single trajectory frame to file.
 
     Format is guessed from the file's extension.
 
     Parameters
     ----------
-    a_universe : :class:`~MDAnalysis.core.universe.Universe`
-        Universe describing the simulation
+    atom_group : :class:`~MDAnalysis.AtomGroup`
+        Atoms from the universe describing the simulation
     iframe : int
         Trajectory frame index (indexes begin with zero)
     file_name : str
         Name of the file to create
     """
-    a_universe.trajectory[iframe]
+    atom_group.universe.trajectory[iframe]
     # Create directory if not existing
     dir_name = os.path.dirname(file_name)
     if dir_name and not os.path.isdir(dir_name):
         os.makedirs(dir_name)
 
     with mda.Writer(file_name) as writer:
-        writer.write(a_universe)
+        writer.write(atom_group)
 
 
 @contextmanager
@@ -58,7 +59,7 @@ def namedtuplefy(func):
 
     Parameters
     ----------
-    func: Function
+    func: function
         Function to be decorated
     name: str
         Class name for the namedtuple. If None, the name of the function
@@ -78,3 +79,52 @@ def wrapper(*args, **kwargs):
         return wrapper.nt(**res)
     wrapper.nt = None
     return wrapper
+
+
+def generate_profile_for_frame(atom_group, iframe, profile_class):
+    r"""
+    Utility function to generate profile properties for a frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframe: int
+        The index of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    Profile for the selected frame
+    """  # noqa: E501
+    with temporary_file(suffix='.pdb') as fname:
+        # Copy the atom group to a new universe to avoid
+        # changing frames upon writing
+        u = atom_group.universe
+        u2 = mda.Universe(u.filename, u.trajectory.filename)
+        atoms2 = u2.atoms[atom_group.atoms.indices]
+        write_frame(atoms2, iframe, fname)
+        return profile_class().from_pdb(fname)
+
+
+def generate_trajectory_profiles(atom_group, iframes, profile_class):
+    r"""
+    Utility function to generate profile properties for each frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframes: List[int]
+        The indices of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    List of the profiles.
+    """  # noqa: E501
+    with multiprocessing.Pool() as p:
+        return p.starmap(generate_profile_for_frame,
+                         [(atom_group, i, profile_class) for i in iframes])
diff --git a/tests/conftest.py b/tests/conftest.py
index 3f42d90..9d58f5b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -106,14 +106,17 @@ def saxs_benchmark():
         'crysol_pdb': absolute path to file.
         'crysol_int': absolute path to file.
         'crysol_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     crysol_file = os.path.join(data_dir, 'saxs', 'crysol.dat')
     crysol_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     crysol_int = os.path.join(data_dir, 'saxs', 'md_0_100.int')
     crysol_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'saxs', 'trajectory_3_profile.dat')
     return dict(crysol_file=crysol_file, crysol_pdb=crysol_pdb,
-                crysol_int=crysol_int, crysol_xtc=crysol_xtc)
+                crysol_int=crysol_int, crysol_xtc=crysol_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
@@ -130,6 +133,7 @@ def sans_benchmark(request):
         'cryson_pdb': absolute path to file.
         'cryson_int': absolute path to file.
         'cryson_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     # setup or initialization
@@ -153,13 +157,15 @@ def sans_benchmark(request):
     cryson_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     cryson_int = os.path.join(data_dir, 'sans', 'md_0_100.int')
     cryson_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'sans', 'trajectory_3_profile.dat')
 
     def teardown():
         handle.close()
     request.addfinalizer(teardown)
     return dict(profiles=handle, property_list=values,
                 tree_with_no_property=tree, cryson_pdb=cryson_pdb,
-                cryson_int=cryson_int, cryson_xtc=cryson_xtc)
+                cryson_int=cryson_int, cryson_xtc=cryson_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
diff --git a/tests/data/sans/trajectory_3_profile.dat b/tests/data/sans/trajectory_3_profile.dat
new file mode 100644
index 0000000..d4af149
--- /dev/null
+++ b/tests/data/sans/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+5.802240000000000000e+05
+5.801650000000000000e+05
+5.800010000000000000e+05
+5.797260000000000000e+05
+5.793430000000000000e+05
+5.788500000000000000e+05
+5.782480000000000000e+05
+5.775380000000000000e+05
+5.767190000000000000e+05
+5.757930000000000000e+05
+5.747590000000000000e+05
+5.736180000000000000e+05
+5.723720000000000000e+05
+5.710190000000000000e+05
+5.695630000000000000e+05
+5.680020000000000000e+05
+5.663380000000000000e+05
+5.645710000000000000e+05
+5.627040000000000000e+05
+5.607360000000000000e+05
+5.586690000000000000e+05
+5.565050000000000000e+05
+5.542430000000000000e+05
+5.518850000000000000e+05
+5.494330000000000000e+05
+5.468880000000000000e+05
+5.442510000000000000e+05
+5.415230000000000000e+05
+5.387060000000000000e+05
+5.358020000000000000e+05
+5.328110000000000000e+05
+5.297360000000000000e+05
+5.265780000000000000e+05
+5.233390000000000000e+05
+5.200210000000000000e+05
+5.166240000000000000e+05
+5.131510000000000000e+05
+5.096030000000000000e+05
+5.059830000000000000e+05
+5.022920000000000000e+05
+4.985320000000000000e+05
+4.947050000000000000e+05
+4.908130000000000000e+05
+4.868570000000000000e+05
+4.828400000000000000e+05
+4.787640000000000000e+05
+4.746300000000000000e+05
+4.704400000000000000e+05
+4.661980000000000000e+05
+4.619030000000000000e+05
+4.575600000000000000e+05
+4.531690000000000000e+05
+4.487330000000000000e+05
+4.442530000000000000e+05
+4.397330000000000000e+05
+4.351730000000000000e+05
+4.305760000000000000e+05
+4.259450000000000000e+05
+4.212800000000000000e+05
+4.165850000000000000e+05
+4.118610000000000000e+05
+4.071100000000000000e+05
+4.023350000000000000e+05
+3.975370000000000000e+05
+3.927190000000000000e+05
+3.878820000000000000e+05
+3.830290000000000000e+05
+3.781610000000000000e+05
+3.732810000000000000e+05
+3.683900000000000000e+05
+3.634910000000000000e+05
+3.585860000000000000e+05
+3.536750000000000000e+05
+3.487620000000000000e+05
+3.438480000000000000e+05
+3.389350000000000000e+05
+3.340250000000000000e+05
+3.291190000000000000e+05
+3.242200000000000000e+05
+3.193290000000000000e+05
+3.144480000000000000e+05
+3.095790000000000000e+05
+3.047220000000000000e+05
+2.998810000000000000e+05
+2.950570000000000000e+05
+2.902500000000000000e+05
+2.854630000000000000e+05
+2.806970000000000000e+05
+2.759540000000000000e+05
+2.712350000000000000e+05
+2.665420000000000000e+05
+2.618750000000000000e+05
+2.572370000000000000e+05
+2.526280000000000000e+05
+2.480500000000000000e+05
+2.435050000000000000e+05
+2.389920000000000000e+05
+2.345140000000000000e+05
+2.300710000000000000e+05
+2.256650000000000000e+05
+2.212960000000000000e+05
+2.169660000000000000e+05
+2.126760000000000000e+05
+2.084260000000000000e+05
+2.042180000000000000e+05
+2.000520000000000000e+05
+1.959290000000000000e+05
+1.918490000000000000e+05
+1.878150000000000000e+05
+1.838250000000000000e+05
+1.798820000000000000e+05
+1.759850000000000000e+05
+1.721350000000000000e+05
+1.683330000000000000e+05
+1.645790000000000000e+05
+1.608740000000000000e+05
+1.572180000000000000e+05
+1.536110000000000000e+05
+1.500540000000000000e+05
+1.465480000000000000e+05
+1.430910000000000000e+05
+1.396860000000000000e+05
+1.363310000000000000e+05
+1.330280000000000000e+05
+1.297760000000000000e+05
+1.265750000000000000e+05
+1.234260000000000000e+05
+1.203280000000000000e+05
+1.172820000000000000e+05
+1.142870000000000000e+05
+1.113450000000000000e+05
+1.084530000000000000e+05
+1.056130000000000000e+05
+1.028250000000000000e+05
+1.000870000000000000e+05
+9.740100000000000000e+04
+9.476550000000000000e+04
+9.218060000000000582e+04
+8.964610000000000582e+04
+8.716169999999999709e+04
+8.472719999999999709e+04
+8.234219999999999709e+04
+8.000639999999999418e+04
+7.771950000000000000e+04
+7.548110000000000582e+04
+7.329080000000000291e+04
+7.114819999999999709e+04
+6.905289999999999418e+04
+6.700450000000000000e+04
+6.500250000000000000e+04
+6.304640000000000146e+04
+6.113580000000000291e+04
+5.927019999999999709e+04
+5.744900000000000000e+04
+5.567180000000000291e+04
+5.393800000000000000e+04
+5.224709999999999854e+04
+5.059840000000000146e+04
+4.899159999999999854e+04
+4.742590000000000146e+04
+4.590080000000000291e+04
+4.441580000000000291e+04
+4.297009999999999854e+04
+4.156330000000000291e+04
+4.019469999999999709e+04
+3.886369999999999709e+04
+3.756980000000000291e+04
+3.631219999999999709e+04
+3.509030000000000291e+04
+3.390359999999999854e+04
+3.275140000000000146e+04
+3.163309999999999854e+04
+3.054800000000000000e+04
+2.949550000000000000e+04
+2.847500000000000000e+04
+2.748590000000000146e+04
+2.652750000000000000e+04
+2.559920000000000073e+04
+2.470040000000000146e+04
+2.383040000000000146e+04
+2.298870000000000073e+04
+2.217459999999999854e+04
+2.138740000000000146e+04
+2.062670000000000073e+04
+1.989170000000000073e+04
+1.918190000000000146e+04
+1.849670000000000073e+04
+1.783540000000000146e+04
+1.719750000000000000e+04
+1.658250000000000000e+04
+1.598960000000000036e+04
+1.541839999999999964e+04
+1.486829999999999927e+04
+1.433879999999999927e+04
+1.382920000000000073e+04
+1.333900000000000000e+04
+1.286779999999999927e+04
+1.241489999999999964e+04
+1.197989999999999964e+04
+1.156210000000000036e+04
+1.116120000000000073e+04
+1.077660000000000036e+04
+1.040789999999999964e+04
+1.005439999999999964e+04
+9.715879999999999200e+03
+9.391700000000000728e+03
+9.081459999999999127e+03
+8.784700000000000728e+03
+8.500969999999999345e+03
+8.229850000000000364e+03
+7.970909999999999854e+03
+7.723729999999999563e+03
+7.487890000000000327e+03
+7.263000000000000000e+03
+7.048659999999999854e+03
+6.844489999999999782e+03
+6.650119999999999891e+03
+6.465170000000000073e+03
+6.289300000000000182e+03
+6.122140000000000327e+03
+5.963359999999999673e+03
+5.812619999999999891e+03
+5.669590000000000146e+03
+5.533970000000000255e+03
+5.405439999999999600e+03
+5.283699999999999818e+03
+5.168449999999999818e+03
+5.059409999999999854e+03
+4.956319999999999709e+03
+4.858880000000000109e+03
+4.766840000000000146e+03
+4.679949999999999818e+03
+4.597960000000000036e+03
+4.520630000000000109e+03
+4.447729999999999563e+03
+4.379050000000000182e+03
+4.314340000000000146e+03
+4.253409999999999854e+03
+4.196050000000000182e+03
+4.142060000000000400e+03
+4.091250000000000000e+03
+4.043440000000000055e+03
+3.998449999999999818e+03
+3.956110000000000127e+03
+3.916250000000000000e+03
+3.878719999999999800e+03
+3.843349999999999909e+03
+3.810019999999999982e+03
+3.778550000000000182e+03
+3.748829999999999927e+03
+3.720719999999999800e+03
+3.694090000000000146e+03
+3.668820000000000164e+03
+3.644820000000000164e+03
+3.621940000000000055e+03
+3.600110000000000127e+03
+3.579210000000000036e+03
+3.559150000000000091e+03
+3.539820000000000164e+03
+3.521159999999999854e+03
+3.503079999999999927e+03
+3.485500000000000000e+03
+3.468329999999999927e+03
+3.451519999999999982e+03
+3.434989999999999782e+03
+3.418679999999999836e+03
+3.402539999999999964e+03
+3.386500000000000000e+03
+3.370519999999999982e+03
+3.354539999999999964e+03
+3.338510000000000218e+03
+3.322409999999999854e+03
+3.306179999999999836e+03
+3.289800000000000182e+03
+3.273210000000000036e+03
+3.256400000000000091e+03
+3.239340000000000146e+03
+3.221989999999999782e+03
+3.204349999999999909e+03
+3.186369999999999891e+03
+3.168050000000000182e+03
+3.149380000000000109e+03
+3.130309999999999945e+03
+3.110860000000000127e+03
+3.091010000000000218e+03
+3.070760000000000218e+03
+3.050099999999999909e+03
+3.029010000000000218e+03
+3.007500000000000000e+03
+2.985559999999999945e+03
+2.963190000000000055e+03
+2.940409999999999854e+03
+2.917190000000000055e+03
+2.893559999999999945e+03
+2.869519999999999982e+03
+2.845059999999999945e+03
+2.820210000000000036e+03
+2.794969999999999800e+03
+2.769340000000000146e+03
+2.743340000000000146e+03
+2.716969999999999800e+03
+2.690239999999999782e+03
+2.663190000000000055e+03
+2.635820000000000164e+03
+2.608130000000000109e+03
+2.580150000000000091e+03
+2.551889999999999873e+03
+2.523349999999999909e+03
+2.494579999999999927e+03
+2.465559999999999945e+03
+2.436340000000000146e+03
+2.406909999999999854e+03
+2.377300000000000182e+03
+2.347519999999999982e+03
+2.317599999999999909e+03
+2.287550000000000182e+03
+2.257380000000000109e+03
+2.227119999999999891e+03
+2.196789999999999964e+03
+2.166409999999999854e+03
+2.135989999999999782e+03
+2.105550000000000182e+03
+2.075110000000000127e+03
+2.044690000000000055e+03
+2.014289999999999964e+03
+1.983960000000000036e+03
+1.953710000000000036e+03
+1.923529999999999973e+03
+1.893460000000000036e+03
+1.863509999999999991e+03
+1.833710000000000036e+03
+1.804049999999999955e+03
+1.774569999999999936e+03
+1.745259999999999991e+03
+1.716180000000000064e+03
+1.687299999999999955e+03
+1.658650000000000091e+03
+1.630250000000000000e+03
+1.602109999999999900e+03
+1.574250000000000000e+03
+1.546670000000000073e+03
+1.519390000000000100e+03
+1.492440000000000055e+03
+1.465799999999999955e+03
+1.439490000000000009e+03
+1.413519999999999982e+03
+1.387910000000000082e+03
+1.362670000000000073e+03
+1.337799999999999955e+03
+1.313309999999999945e+03
+1.289220000000000027e+03
+1.265529999999999973e+03
+1.242240000000000009e+03
+1.219359999999999900e+03
+1.196900000000000091e+03
+1.174880000000000109e+03
+1.153279999999999973e+03
+1.132109999999999900e+03
+1.111380000000000109e+03
+1.091099999999999909e+03
+1.071259999999999991e+03
+1.051869999999999891e+03
+1.032940000000000055e+03
+1.014460000000000036e+03
+9.964370000000000118e+02
+9.788659999999999854e+02
+9.617509999999999764e+02
+9.450940000000000509e+02
+9.288959999999999582e+02
+9.131539999999999964e+02
+8.978579999999999472e+02
+8.830199999999999818e+02
+8.686309999999999718e+02
+8.546960000000000264e+02
+8.412010000000000218e+02
+8.281559999999999491e+02
+8.155470000000000255e+02
+8.033750000000000000e+02
+7.916319999999999482e+02
+7.803170000000000073e+02
+7.694260000000000446e+02
+7.589539999999999509e+02
+7.488949999999999818e+02
+7.392390000000000327e+02
+7.299819999999999709e+02
+7.211159999999999854e+02
+7.126430000000000291e+02
+7.045470000000000255e+02
+6.968310000000000173e+02
+6.894800000000000182e+02
+6.824900000000000091e+02
+6.758569999999999709e+02
+6.695539999999999736e+02
+6.636000000000000227e+02
+6.579759999999999991e+02
+6.526710000000000491e+02
+6.476839999999999691e+02
+6.430069999999999482e+02
+6.386230000000000473e+02
+6.345380000000000109e+02
+6.307219999999999800e+02
+6.271839999999999691e+02
+6.239109999999999445e+02
+6.208949999999999818e+02
+6.181130000000000564e+02
+6.155750000000000455e+02
+6.132609999999999673e+02
+6.111749999999999545e+02
+6.093049999999999500e+02
+6.076230000000000473e+02
+6.061449999999999818e+02
+6.048609999999999900e+02
+6.037649999999999864e+02
+6.028260000000000218e+02
+6.020579999999999927e+02
+6.014349999999999454e+02
+6.009569999999999936e+02
+6.006299999999999955e+02
+6.004329999999999927e+02
+6.003479999999999563e+02
+6.003840000000000146e+02
+6.005249999999999773e+02
+6.007680000000000291e+02
+6.011040000000000418e+02
+6.015270000000000437e+02
+6.020240000000000009e+02
+6.025940000000000509e+02
+6.032309999999999945e+02
+6.039210000000000491e+02
+6.046649999999999636e+02
+6.054539999999999509e+02
+6.062899999999999636e+02
+6.071589999999999918e+02
+6.080460000000000491e+02
+6.089679999999999609e+02
+6.099109999999999445e+02
+6.108600000000000136e+02
+6.118160000000000309e+02
+6.127690000000000055e+02
+6.137329999999999472e+02
+6.146860000000000355e+02
+6.156290000000000191e+02
+6.165549999999999500e+02
+6.174610000000000127e+02
+6.183410000000000082e+02
+6.192000000000000455e+02
+6.200349999999999682e+02
+6.208339999999999463e+02
+6.216090000000000373e+02
+6.223390000000000555e+02
+6.230399999999999636e+02
+6.236839999999999691e+02
+6.242839999999999918e+02
+6.248379999999999654e+02
+6.253460000000000036e+02
+6.258070000000000164e+02
+6.262100000000000364e+02
+6.265629999999999882e+02
+6.268690000000000282e+02
+6.271159999999999854e+02
+6.273060000000000400e+02
+6.274339999999999691e+02
+6.275090000000000146e+02
+6.275199999999999818e+02
+6.274750000000000227e+02
+6.273640000000000327e+02
+6.272019999999999982e+02
+6.269859999999999900e+02
+6.267129999999999654e+02
+6.263740000000000236e+02
+6.259829999999999472e+02
+6.255389999999999873e+02
+6.250420000000000300e+02
+6.244900000000000091e+02
+6.238790000000000191e+02
+6.232110000000000127e+02
+6.224919999999999618e+02
+6.217190000000000509e+02
+6.209020000000000437e+02
+6.200330000000000155e+02
+6.191109999999999900e+02
+6.181499999999999773e+02
+6.171359999999999673e+02
+6.160839999999999463e+02
+6.149829999999999472e+02
+6.138429999999999609e+02
+6.126649999999999636e+02
+6.114560000000000173e+02
+6.102129999999999654e+02
+6.089270000000000209e+02
+6.076250000000000000e+02
+6.062740000000000009e+02
+6.049009999999999536e+02
+6.035019999999999527e+02
+6.020819999999999936e+02
+6.006319999999999482e+02
+5.991689999999999827e+02
+5.976789999999999736e+02
+5.961749999999999545e+02
+5.946499999999999773e+02
diff --git a/tests/data/saxs/trajectory_3_profile.dat b/tests/data/saxs/trajectory_3_profile.dat
new file mode 100644
index 0000000..effca13
--- /dev/null
+++ b/tests/data/saxs/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+8.128970000000000000e+06
+8.127820000000000000e+06
+8.124460000000000000e+06
+8.118860000000000000e+06
+8.111030000000000000e+06
+8.100960000000000000e+06
+8.088680000000000000e+06
+8.074190000000000000e+06
+8.057500000000000000e+06
+8.038620000000000000e+06
+8.017570000000000000e+06
+7.994370000000000000e+06
+7.969010000000000000e+06
+7.941560000000000000e+06
+7.912050000000000000e+06
+7.880380000000000000e+06
+7.846770000000000000e+06
+7.811090000000000000e+06
+7.773290000000000000e+06
+7.733740000000000000e+06
+7.692170000000000000e+06
+7.648590000000000000e+06
+7.603150000000000000e+06
+7.555830000000000000e+06
+7.506850000000000000e+06
+7.455980000000000000e+06
+7.403430000000000000e+06
+7.349180000000000000e+06
+7.293250000000000000e+06
+7.235750000000000000e+06
+7.176640000000000000e+06
+7.116040000000000000e+06
+7.053900000000000000e+06
+6.990350000000000000e+06
+6.925400000000000000e+06
+6.859120000000000000e+06
+6.791510000000000000e+06
+6.722650000000000000e+06
+6.652600000000000000e+06
+6.581370000000000000e+06
+6.509050000000000000e+06
+6.435670000000000000e+06
+6.361270000000000000e+06
+6.285910000000000000e+06
+6.209630000000000000e+06
+6.132510000000000000e+06
+6.054570000000000000e+06
+5.975880000000000000e+06
+5.896470000000000000e+06
+5.816410000000000000e+06
+5.735750000000000000e+06
+5.654530000000000000e+06
+5.572820000000000000e+06
+5.490650000000000000e+06
+5.408070000000000000e+06
+5.325140000000000000e+06
+5.241910000000000000e+06
+5.158420000000000000e+06
+5.074740000000000000e+06
+4.990890000000000000e+06
+4.906940000000000000e+06
+4.822920000000000000e+06
+4.738890000000000000e+06
+4.654890000000000000e+06
+4.570970000000000000e+06
+4.487180000000000000e+06
+4.403540000000000000e+06
+4.320120000000000000e+06
+4.236940000000000000e+06
+4.154060000000000000e+06
+4.071520000000000000e+06
+3.989340000000000000e+06
+3.907580000000000000e+06
+3.826270000000000000e+06
+3.745440000000000000e+06
+3.665130000000000000e+06
+3.585390000000000000e+06
+3.506230000000000000e+06
+3.427700000000000000e+06
+3.349820000000000000e+06
+3.272630000000000000e+06
+3.196160000000000000e+06
+3.120430000000000000e+06
+3.045470000000000000e+06
+2.971310000000000000e+06
+2.897970000000000000e+06
+2.825480000000000000e+06
+2.753850000000000000e+06
+2.683120000000000000e+06
+2.613300000000000000e+06
+2.544400000000000000e+06
+2.476460000000000000e+06
+2.409480000000000000e+06
+2.343480000000000000e+06
+2.278480000000000000e+06
+2.214490000000000000e+06
+2.151520000000000000e+06
+2.089580000000000000e+06
+2.028690000000000000e+06
+1.968840000000000000e+06
+1.910060000000000000e+06
+1.852350000000000000e+06
+1.795710000000000000e+06
+1.740150000000000000e+06
+1.685680000000000000e+06
+1.632290000000000000e+06
+1.579980000000000000e+06
+1.528770000000000000e+06
+1.478650000000000000e+06
+1.429610000000000000e+06
+1.381670000000000000e+06
+1.334800000000000000e+06
+1.289020000000000000e+06
+1.244320000000000000e+06
+1.200690000000000000e+06
+1.158130000000000000e+06
+1.116630000000000000e+06
+1.076180000000000000e+06
+1.036770000000000000e+06
+9.984100000000000000e+05
+9.610740000000000000e+05
+9.247570000000000000e+05
+8.894490000000000000e+05
+8.551380000000000000e+05
+8.218150000000000000e+05
+7.894660000000000000e+05
+7.580790000000000000e+05
+7.276430000000000000e+05
+6.981430000000000000e+05
+6.695670000000000000e+05
+6.419000000000000000e+05
+6.151280000000000000e+05
+5.892370000000000000e+05
+5.642120000000000000e+05
+5.400370000000000000e+05
+5.166980000000000000e+05
+4.941770000000000000e+05
+4.724610000000000000e+05
+4.515330000000000000e+05
+4.313770000000000000e+05
+4.119760000000000000e+05
+3.933140000000000000e+05
+3.753750000000000000e+05
+3.581430000000000000e+05
+3.416000000000000000e+05
+3.257310000000000000e+05
+3.105180000000000000e+05
+2.959450000000000000e+05
+2.819960000000000000e+05
+2.686530000000000000e+05
+2.559010000000000000e+05
+2.437240000000000000e+05
+2.321050000000000000e+05
+2.210270000000000000e+05
+2.104750000000000000e+05
+2.004340000000000000e+05
+1.908870000000000000e+05
+1.818180000000000000e+05
+1.732120000000000000e+05
+1.650550000000000000e+05
+1.573310000000000000e+05
+1.500240000000000000e+05
+1.431220000000000000e+05
+1.366090000000000000e+05
+1.304700000000000000e+05
+1.246940000000000000e+05
+1.192640000000000000e+05
+1.141680000000000000e+05
+1.093940000000000000e+05
+1.049270000000000000e+05
+1.007560000000000000e+05
+9.686700000000000000e+04
+9.324910000000000582e+04
+8.989030000000000291e+04
+8.677860000000000582e+04
+8.390319999999999709e+04
+8.125269999999999709e+04
+7.881660000000000582e+04
+7.658430000000000291e+04
+7.454569999999999709e+04
+7.269089999999999418e+04
+7.101030000000000291e+04
+6.949450000000000000e+04
+6.813450000000000000e+04
+6.692150000000000000e+04
+6.584710000000000582e+04
+6.490269999999999709e+04
+6.408100000000000000e+04
+6.337380000000000291e+04
+6.277369999999999709e+04
+6.227380000000000291e+04
+6.186709999999999854e+04
+6.154690000000000146e+04
+6.130669999999999709e+04
+6.114059999999999854e+04
+6.104240000000000146e+04
+6.100659999999999854e+04
+6.102759999999999854e+04
+6.110040000000000146e+04
+6.122000000000000000e+04
+6.138140000000000146e+04
+6.158030000000000291e+04
+6.181230000000000291e+04
+6.207340000000000146e+04
+6.235980000000000291e+04
+6.266700000000000000e+04
+6.299240000000000146e+04
+6.333200000000000000e+04
+6.368290000000000146e+04
+6.404180000000000291e+04
+6.440619999999999709e+04
+6.477340000000000146e+04
+6.514090000000000146e+04
+6.550630000000000291e+04
+6.586750000000000000e+04
+6.622210000000000582e+04
+6.656850000000000000e+04
+6.690489999999999418e+04
+6.722950000000000000e+04
+6.754110000000000582e+04
+6.783810000000000582e+04
+6.811919999999999709e+04
+6.838339999999999418e+04
+6.862939999999999418e+04
+6.885650000000000000e+04
+6.906360000000000582e+04
+6.925010000000000582e+04
+6.941539999999999418e+04
+6.955860000000000582e+04
+6.967950000000000000e+04
+6.977789999999999418e+04
+6.985289999999999418e+04
+6.990460000000000582e+04
+6.993280000000000291e+04
+6.993739999999999418e+04
+6.991810000000000582e+04
+6.987500000000000000e+04
+6.980830000000000291e+04
+6.971800000000000000e+04
+6.960400000000000000e+04
+6.946700000000000000e+04
+6.930680000000000291e+04
+6.912419999999999709e+04
+6.891889999999999418e+04
+6.869180000000000291e+04
+6.844269999999999709e+04
+6.817269999999999709e+04
+6.788180000000000291e+04
+6.757069999999999709e+04
+6.723989999999999418e+04
+6.688939999999999418e+04
+6.652060000000000582e+04
+6.613369999999999709e+04
+6.572930000000000291e+04
+6.530809999999999854e+04
+6.487009999999999854e+04
+6.441669999999999709e+04
+6.394819999999999709e+04
+6.346559999999999854e+04
+6.296880000000000291e+04
+6.245909999999999854e+04
+6.193690000000000146e+04
+6.140259999999999854e+04
+6.085730000000000291e+04
+6.030180000000000291e+04
+5.973659999999999854e+04
+5.916230000000000291e+04
+5.857950000000000000e+04
+5.798890000000000146e+04
+5.739119999999999709e+04
+5.678709999999999854e+04
+5.617690000000000146e+04
+5.556150000000000000e+04
+5.494169999999999709e+04
+5.431830000000000291e+04
+5.369130000000000291e+04
+5.306159999999999854e+04
+5.242990000000000146e+04
+5.179669999999999709e+04
+5.116240000000000146e+04
+5.052769999999999709e+04
+4.989309999999999854e+04
+4.925930000000000291e+04
+4.862690000000000146e+04
+4.799630000000000291e+04
+4.736759999999999854e+04
+4.674150000000000000e+04
+4.611919999999999709e+04
+4.550009999999999854e+04
+4.488480000000000291e+04
+4.427400000000000000e+04
+4.366809999999999854e+04
+4.306759999999999854e+04
+4.247269999999999709e+04
+4.188350000000000000e+04
+4.130080000000000291e+04
+4.072469999999999709e+04
+4.015569999999999709e+04
+3.959400000000000000e+04
+3.903980000000000291e+04
+3.849319999999999709e+04
+3.795500000000000000e+04
+3.742480000000000291e+04
+3.690319999999999709e+04
+3.639040000000000146e+04
+3.588650000000000000e+04
+3.539159999999999854e+04
+3.490609999999999854e+04
+3.442990000000000146e+04
+3.396319999999999709e+04
+3.350630000000000291e+04
+3.305900000000000000e+04
+3.262190000000000146e+04
+3.219470000000000073e+04
+3.177709999999999854e+04
+3.136959999999999854e+04
+3.097240000000000146e+04
+3.058540000000000146e+04
+3.020840000000000146e+04
+2.984150000000000000e+04
+2.948500000000000000e+04
+2.913840000000000146e+04
+2.880190000000000146e+04
+2.847540000000000146e+04
+2.815879999999999927e+04
+2.785290000000000146e+04
+2.755629999999999927e+04
+2.726959999999999854e+04
+2.699270000000000073e+04
+2.672540000000000146e+04
+2.646750000000000000e+04
+2.621929999999999927e+04
+2.598020000000000073e+04
+2.575090000000000146e+04
+2.553020000000000073e+04
+2.531850000000000000e+04
+2.511550000000000000e+04
+2.492140000000000146e+04
+2.473590000000000146e+04
+2.455870000000000073e+04
+2.439000000000000000e+04
+2.422909999999999854e+04
+2.407620000000000073e+04
+2.393109999999999854e+04
+2.379359999999999854e+04
+2.366350000000000000e+04
+2.354070000000000073e+04
+2.342500000000000000e+04
+2.331620000000000073e+04
+2.321400000000000000e+04
+2.311850000000000000e+04
+2.302950000000000000e+04
+2.294659999999999854e+04
+2.286970000000000073e+04
+2.279870000000000073e+04
+2.273359999999999854e+04
+2.267379999999999927e+04
+2.261940000000000146e+04
+2.257000000000000000e+04
+2.252570000000000073e+04
+2.248609999999999854e+04
+2.245129999999999927e+04
+2.242070000000000073e+04
+2.239470000000000073e+04
+2.237279999999999927e+04
+2.235459999999999854e+04
+2.234020000000000073e+04
+2.232950000000000000e+04
+2.232229999999999927e+04
+2.231840000000000146e+04
+2.231770000000000073e+04
+2.231940000000000146e+04
+2.232470000000000073e+04
+2.233240000000000146e+04
+2.234270000000000073e+04
+2.235559999999999854e+04
+2.237070000000000073e+04
+2.238790000000000146e+04
+2.240720000000000073e+04
+2.242840000000000146e+04
+2.245109999999999854e+04
+2.247570000000000073e+04
+2.250159999999999854e+04
+2.252909999999999854e+04
+2.255759999999999854e+04
+2.258729999999999927e+04
+2.261840000000000146e+04
+2.265040000000000146e+04
+2.268309999999999854e+04
+2.271659999999999854e+04
+2.275059999999999854e+04
+2.278529999999999927e+04
+2.282040000000000146e+04
+2.285600000000000000e+04
+2.289200000000000000e+04
+2.292809999999999854e+04
+2.296420000000000073e+04
+2.300029999999999927e+04
+2.303670000000000073e+04
+2.307250000000000000e+04
+2.310870000000000073e+04
+2.314440000000000146e+04
+2.318000000000000000e+04
+2.321500000000000000e+04
+2.324970000000000073e+04
+2.328429999999999927e+04
+2.331809999999999854e+04
+2.335120000000000073e+04
+2.338390000000000146e+04
+2.341579999999999927e+04
+2.344720000000000073e+04
+2.347779999999999927e+04
+2.350759999999999854e+04
+2.353659999999999854e+04
+2.356470000000000073e+04
+2.359170000000000073e+04
+2.361800000000000000e+04
+2.364309999999999854e+04
+2.366759999999999854e+04
+2.369100000000000000e+04
+2.371350000000000000e+04
+2.373479999999999927e+04
+2.375520000000000073e+04
+2.377440000000000146e+04
+2.379259999999999854e+04
+2.380970000000000073e+04
+2.382559999999999854e+04
+2.384079999999999927e+04
+2.385459999999999854e+04
+2.386729999999999927e+04
+2.387879999999999927e+04
+2.388909999999999854e+04
+2.389840000000000146e+04
+2.390640000000000146e+04
+2.391320000000000073e+04
+2.391890000000000146e+04
+2.392329999999999927e+04
+2.392659999999999854e+04
+2.392890000000000146e+04
+2.392950000000000000e+04
+2.392920000000000073e+04
+2.392750000000000000e+04
+2.392500000000000000e+04
+2.392190000000000146e+04
+2.391700000000000000e+04
+2.391109999999999854e+04
+2.390400000000000000e+04
+2.389590000000000146e+04
+2.388650000000000000e+04
+2.387629999999999927e+04
+2.386490000000000146e+04
+2.385229999999999927e+04
+2.383870000000000073e+04
+2.382420000000000073e+04
+2.380859999999999854e+04
+2.379200000000000000e+04
+2.377459999999999854e+04
+2.375590000000000146e+04
+2.373620000000000073e+04
+2.371559999999999854e+04
+2.369429999999999927e+04
+2.367190000000000146e+04
+2.364900000000000000e+04
+2.362470000000000073e+04
+2.359970000000000073e+04
+2.357370000000000073e+04
+2.354670000000000073e+04
+2.351890000000000146e+04
+2.349029999999999927e+04
+2.346079999999999927e+04
+2.343059999999999854e+04
+2.339979999999999927e+04
+2.336800000000000000e+04
+2.333529999999999927e+04
+2.330200000000000000e+04
+2.326790000000000146e+04
+2.323309999999999854e+04
+2.319750000000000000e+04
+2.316120000000000073e+04
+2.312420000000000073e+04
+2.308659999999999854e+04
+2.304820000000000073e+04
+2.300909999999999854e+04
+2.296929999999999927e+04
+2.292900000000000000e+04
+2.288790000000000146e+04
+2.284629999999999927e+04
+2.280390000000000146e+04
+2.276079999999999927e+04
+2.271720000000000073e+04
+2.267300000000000000e+04
+2.262820000000000073e+04
+2.258290000000000146e+04
+2.253679999999999927e+04
+2.249040000000000146e+04
+2.244300000000000000e+04
+2.239509999999999854e+04
+2.234659999999999854e+04
+2.229750000000000000e+04
+2.224800000000000000e+04
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 14870ea..cfe443b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,7 +1,11 @@
 import os
 import pytest
+import numpy as np
+import MDAnalysis as mda
+import shutil
 
 from idpflex import utils
+from idpflex.properties import SaxsProperty, SansProperty
 
 
 def test_write_frame(trajectory_benchmark):
@@ -12,5 +16,21 @@ def test_write_frame(trajectory_benchmark):
     os.remove('test.pdb')
 
 
+@pytest.mark.skipif(shutil.which('cryson') is None
+                    or shutil.which('crysol') is None, reason='Needs cryson')
+def test_generate_trajectory_profiles(saxs_benchmark, sans_benchmark):
+    saxs_ref = np.loadtxt(saxs_benchmark['frame_profile'])
+    sans_ref = np.loadtxt(sans_benchmark['frame_profile'])
+    universe = mda.Universe(saxs_benchmark['crysol_pdb'],
+                            saxs_benchmark['crysol_xtc'])
+    protein = universe.select_atoms('protein')
+    saxs_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SaxsProperty)[3].profile
+    sans_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SansProperty)[3].profile
+    np.testing.assert_array_almost_equal(saxs_ref, saxs_prof)
+    np.testing.assert_array_almost_equal(sans_ref, sans_prof)
+
+
 if __name__ == '__main__':
     pytest.main()

From 1f6fae032e7532febfa1bed9bc4091e53a21bf22 Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Wed, 12 Jun 2019 12:04:43 -0400
Subject: [PATCH 4/6] Cache pip dependencies.

---
 .travis.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 512925a..6673668 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,8 @@ python:
   - "3.7"
   - "3.6"
 
+cache: pip
+
 env: PYTHONPATH=$PYTHONPATH:$TRAVIS_BUILD_DIR/tests
 
 before_install:

From 513f68fdf84a319106a004689bf0846239afc79a Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Tue, 11 Jun 2019 18:16:02 -0400
Subject: [PATCH 5/6] Closes #92 by calculating trajectories for entire
 profiles.

---
 idpflex/properties.py                    |   2 +
 idpflex/utils.py                         |  62 ++-
 tests/conftest.py                        |  10 +-
 tests/data/sans/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/data/saxs/trajectory_3_profile.dat | 500 +++++++++++++++++++++++
 tests/test_utils.py                      |  20 +
 6 files changed, 1086 insertions(+), 8 deletions(-)
 create mode 100644 tests/data/sans/trajectory_3_profile.dat
 create mode 100644 tests/data/saxs/trajectory_3_profile.dat

diff --git a/idpflex/properties.py b/idpflex/properties.py
index 129c098..e1d5dce 100644
--- a/idpflex/properties.py
+++ b/idpflex/properties.py
@@ -1372,6 +1372,7 @@ class SansProperty(ProfileProperty, SansLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_cryson_pdb
         if self.name is None:
             self.name = SansProperty.default_name
 
@@ -1510,6 +1511,7 @@ class SaxsProperty(ProfileProperty, SaxsLoaderMixin):
 
     def __init__(self, *args, **kwargs):
         ProfileProperty.__init__(self, *args, **kwargs)
+        self.from_pdb = self.from_crysol_pdb
         if self.name is None:
             self.name = SaxsProperty.default_name
 
diff --git a/idpflex/utils.py b/idpflex/utils.py
index fb1e54a..10bcbbd 100644
--- a/idpflex/utils.py
+++ b/idpflex/utils.py
@@ -2,33 +2,34 @@
 from contextlib import contextmanager
 import tempfile
 import functools
+import multiprocessing
 from collections import namedtuple, Mapping
 
 import MDAnalysis as mda
 
 
-def write_frame(a_universe, iframe, file_name):
+def write_frame(atom_group, iframe, file_name):
     r"""Write a single trajectory frame to file.
 
     Format is guessed from the file's extension.
 
     Parameters
     ----------
-    a_universe : :class:`~MDAnalysis.core.universe.Universe`
-        Universe describing the simulation
+    atom_group : :class:`~MDAnalysis.AtomGroup`
+        Atoms from the universe describing the simulation
     iframe : int
         Trajectory frame index (indexes begin with zero)
     file_name : str
         Name of the file to create
     """
-    a_universe.trajectory[iframe]
+    atom_group.universe.trajectory[iframe]
     # Create directory if not existing
     dir_name = os.path.dirname(file_name)
     if dir_name and not os.path.isdir(dir_name):
         os.makedirs(dir_name)
 
     with mda.Writer(file_name) as writer:
-        writer.write(a_universe)
+        writer.write(atom_group)
 
 
 @contextmanager
@@ -58,7 +59,7 @@ def namedtuplefy(func):
 
     Parameters
     ----------
-    func: Function
+    func: function
         Function to be decorated
     name: str
         Class name for the namedtuple. If None, the name of the function
@@ -78,3 +79,52 @@ def wrapper(*args, **kwargs):
         return wrapper.nt(**res)
     wrapper.nt = None
     return wrapper
+
+
+def generate_profile_for_frame(atom_group, iframe, profile_class):
+    r"""
+    Utility function to generate profile properties for a frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframe: int
+        The index of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    Profile for the selected frame
+    """  # noqa: E501
+    with temporary_file(suffix='.pdb') as fname:
+        # Copy the atom group to a new universe to avoid
+        # changing frames upon writing
+        u = atom_group.universe
+        u2 = mda.Universe(u.filename, u.trajectory.filename)
+        atoms2 = u2.atoms[atom_group.atoms.indices]
+        write_frame(atoms2, iframe, fname)
+        return profile_class().from_pdb(fname)
+
+
+def generate_trajectory_profiles(atom_group, iframes, profile_class):
+    r"""
+    Utility function to generate profile properties for each frame in a trajectory.
+
+    Parameters
+    ----------
+    atom_group: :class:`MDAnalysis.AtomGroup`
+        The atom group representing the structure to calculate the profile for.
+    iframes: List[int]
+        The indices of a trajectory for which to calculate profiles of the associated atom_group.
+    profile_class:
+        The profile class to use for the properties to be returned and calculated. Must implement a `from_pdb` method.
+
+    Returns
+    -------
+    List of the profiles.
+    """  # noqa: E501
+    with multiprocessing.Pool() as p:
+        return p.starmap(generate_profile_for_frame,
+                         [(atom_group, i, profile_class) for i in iframes])
diff --git a/tests/conftest.py b/tests/conftest.py
index 3f42d90..9d58f5b 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -106,14 +106,17 @@ def saxs_benchmark():
         'crysol_pdb': absolute path to file.
         'crysol_int': absolute path to file.
         'crysol_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     crysol_file = os.path.join(data_dir, 'saxs', 'crysol.dat')
     crysol_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     crysol_int = os.path.join(data_dir, 'saxs', 'md_0_100.int')
     crysol_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'saxs', 'trajectory_3_profile.dat')
     return dict(crysol_file=crysol_file, crysol_pdb=crysol_pdb,
-                crysol_int=crysol_int, crysol_xtc=crysol_xtc)
+                crysol_int=crysol_int, crysol_xtc=crysol_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
@@ -130,6 +133,7 @@ def sans_benchmark(request):
         'cryson_pdb': absolute path to file.
         'cryson_int': absolute path to file.
         'cryson_xtc': absolute path to file.
+        'frame_profile': absolute path to file.
     """
 
     # setup or initialization
@@ -153,13 +157,15 @@ def sans_benchmark(request):
     cryson_pdb = os.path.join(data_dir, 'saxs', 'md_0_1.pdb')
     cryson_int = os.path.join(data_dir, 'sans', 'md_0_100.int')
     cryson_xtc = os.path.join(data_dir, 'saxs', 'md_0_1_noPBC.xtc')
+    frame_profile = os.path.join(data_dir, 'sans', 'trajectory_3_profile.dat')
 
     def teardown():
         handle.close()
     request.addfinalizer(teardown)
     return dict(profiles=handle, property_list=values,
                 tree_with_no_property=tree, cryson_pdb=cryson_pdb,
-                cryson_int=cryson_int, cryson_xtc=cryson_xtc)
+                cryson_int=cryson_int, cryson_xtc=cryson_xtc,
+                frame_profile=frame_profile)
 
 
 @pytest.fixture(scope='session')
diff --git a/tests/data/sans/trajectory_3_profile.dat b/tests/data/sans/trajectory_3_profile.dat
new file mode 100644
index 0000000..d4af149
--- /dev/null
+++ b/tests/data/sans/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+5.802240000000000000e+05
+5.801650000000000000e+05
+5.800010000000000000e+05
+5.797260000000000000e+05
+5.793430000000000000e+05
+5.788500000000000000e+05
+5.782480000000000000e+05
+5.775380000000000000e+05
+5.767190000000000000e+05
+5.757930000000000000e+05
+5.747590000000000000e+05
+5.736180000000000000e+05
+5.723720000000000000e+05
+5.710190000000000000e+05
+5.695630000000000000e+05
+5.680020000000000000e+05
+5.663380000000000000e+05
+5.645710000000000000e+05
+5.627040000000000000e+05
+5.607360000000000000e+05
+5.586690000000000000e+05
+5.565050000000000000e+05
+5.542430000000000000e+05
+5.518850000000000000e+05
+5.494330000000000000e+05
+5.468880000000000000e+05
+5.442510000000000000e+05
+5.415230000000000000e+05
+5.387060000000000000e+05
+5.358020000000000000e+05
+5.328110000000000000e+05
+5.297360000000000000e+05
+5.265780000000000000e+05
+5.233390000000000000e+05
+5.200210000000000000e+05
+5.166240000000000000e+05
+5.131510000000000000e+05
+5.096030000000000000e+05
+5.059830000000000000e+05
+5.022920000000000000e+05
+4.985320000000000000e+05
+4.947050000000000000e+05
+4.908130000000000000e+05
+4.868570000000000000e+05
+4.828400000000000000e+05
+4.787640000000000000e+05
+4.746300000000000000e+05
+4.704400000000000000e+05
+4.661980000000000000e+05
+4.619030000000000000e+05
+4.575600000000000000e+05
+4.531690000000000000e+05
+4.487330000000000000e+05
+4.442530000000000000e+05
+4.397330000000000000e+05
+4.351730000000000000e+05
+4.305760000000000000e+05
+4.259450000000000000e+05
+4.212800000000000000e+05
+4.165850000000000000e+05
+4.118610000000000000e+05
+4.071100000000000000e+05
+4.023350000000000000e+05
+3.975370000000000000e+05
+3.927190000000000000e+05
+3.878820000000000000e+05
+3.830290000000000000e+05
+3.781610000000000000e+05
+3.732810000000000000e+05
+3.683900000000000000e+05
+3.634910000000000000e+05
+3.585860000000000000e+05
+3.536750000000000000e+05
+3.487620000000000000e+05
+3.438480000000000000e+05
+3.389350000000000000e+05
+3.340250000000000000e+05
+3.291190000000000000e+05
+3.242200000000000000e+05
+3.193290000000000000e+05
+3.144480000000000000e+05
+3.095790000000000000e+05
+3.047220000000000000e+05
+2.998810000000000000e+05
+2.950570000000000000e+05
+2.902500000000000000e+05
+2.854630000000000000e+05
+2.806970000000000000e+05
+2.759540000000000000e+05
+2.712350000000000000e+05
+2.665420000000000000e+05
+2.618750000000000000e+05
+2.572370000000000000e+05
+2.526280000000000000e+05
+2.480500000000000000e+05
+2.435050000000000000e+05
+2.389920000000000000e+05
+2.345140000000000000e+05
+2.300710000000000000e+05
+2.256650000000000000e+05
+2.212960000000000000e+05
+2.169660000000000000e+05
+2.126760000000000000e+05
+2.084260000000000000e+05
+2.042180000000000000e+05
+2.000520000000000000e+05
+1.959290000000000000e+05
+1.918490000000000000e+05
+1.878150000000000000e+05
+1.838250000000000000e+05
+1.798820000000000000e+05
+1.759850000000000000e+05
+1.721350000000000000e+05
+1.683330000000000000e+05
+1.645790000000000000e+05
+1.608740000000000000e+05
+1.572180000000000000e+05
+1.536110000000000000e+05
+1.500540000000000000e+05
+1.465480000000000000e+05
+1.430910000000000000e+05
+1.396860000000000000e+05
+1.363310000000000000e+05
+1.330280000000000000e+05
+1.297760000000000000e+05
+1.265750000000000000e+05
+1.234260000000000000e+05
+1.203280000000000000e+05
+1.172820000000000000e+05
+1.142870000000000000e+05
+1.113450000000000000e+05
+1.084530000000000000e+05
+1.056130000000000000e+05
+1.028250000000000000e+05
+1.000870000000000000e+05
+9.740100000000000000e+04
+9.476550000000000000e+04
+9.218060000000000582e+04
+8.964610000000000582e+04
+8.716169999999999709e+04
+8.472719999999999709e+04
+8.234219999999999709e+04
+8.000639999999999418e+04
+7.771950000000000000e+04
+7.548110000000000582e+04
+7.329080000000000291e+04
+7.114819999999999709e+04
+6.905289999999999418e+04
+6.700450000000000000e+04
+6.500250000000000000e+04
+6.304640000000000146e+04
+6.113580000000000291e+04
+5.927019999999999709e+04
+5.744900000000000000e+04
+5.567180000000000291e+04
+5.393800000000000000e+04
+5.224709999999999854e+04
+5.059840000000000146e+04
+4.899159999999999854e+04
+4.742590000000000146e+04
+4.590080000000000291e+04
+4.441580000000000291e+04
+4.297009999999999854e+04
+4.156330000000000291e+04
+4.019469999999999709e+04
+3.886369999999999709e+04
+3.756980000000000291e+04
+3.631219999999999709e+04
+3.509030000000000291e+04
+3.390359999999999854e+04
+3.275140000000000146e+04
+3.163309999999999854e+04
+3.054800000000000000e+04
+2.949550000000000000e+04
+2.847500000000000000e+04
+2.748590000000000146e+04
+2.652750000000000000e+04
+2.559920000000000073e+04
+2.470040000000000146e+04
+2.383040000000000146e+04
+2.298870000000000073e+04
+2.217459999999999854e+04
+2.138740000000000146e+04
+2.062670000000000073e+04
+1.989170000000000073e+04
+1.918190000000000146e+04
+1.849670000000000073e+04
+1.783540000000000146e+04
+1.719750000000000000e+04
+1.658250000000000000e+04
+1.598960000000000036e+04
+1.541839999999999964e+04
+1.486829999999999927e+04
+1.433879999999999927e+04
+1.382920000000000073e+04
+1.333900000000000000e+04
+1.286779999999999927e+04
+1.241489999999999964e+04
+1.197989999999999964e+04
+1.156210000000000036e+04
+1.116120000000000073e+04
+1.077660000000000036e+04
+1.040789999999999964e+04
+1.005439999999999964e+04
+9.715879999999999200e+03
+9.391700000000000728e+03
+9.081459999999999127e+03
+8.784700000000000728e+03
+8.500969999999999345e+03
+8.229850000000000364e+03
+7.970909999999999854e+03
+7.723729999999999563e+03
+7.487890000000000327e+03
+7.263000000000000000e+03
+7.048659999999999854e+03
+6.844489999999999782e+03
+6.650119999999999891e+03
+6.465170000000000073e+03
+6.289300000000000182e+03
+6.122140000000000327e+03
+5.963359999999999673e+03
+5.812619999999999891e+03
+5.669590000000000146e+03
+5.533970000000000255e+03
+5.405439999999999600e+03
+5.283699999999999818e+03
+5.168449999999999818e+03
+5.059409999999999854e+03
+4.956319999999999709e+03
+4.858880000000000109e+03
+4.766840000000000146e+03
+4.679949999999999818e+03
+4.597960000000000036e+03
+4.520630000000000109e+03
+4.447729999999999563e+03
+4.379050000000000182e+03
+4.314340000000000146e+03
+4.253409999999999854e+03
+4.196050000000000182e+03
+4.142060000000000400e+03
+4.091250000000000000e+03
+4.043440000000000055e+03
+3.998449999999999818e+03
+3.956110000000000127e+03
+3.916250000000000000e+03
+3.878719999999999800e+03
+3.843349999999999909e+03
+3.810019999999999982e+03
+3.778550000000000182e+03
+3.748829999999999927e+03
+3.720719999999999800e+03
+3.694090000000000146e+03
+3.668820000000000164e+03
+3.644820000000000164e+03
+3.621940000000000055e+03
+3.600110000000000127e+03
+3.579210000000000036e+03
+3.559150000000000091e+03
+3.539820000000000164e+03
+3.521159999999999854e+03
+3.503079999999999927e+03
+3.485500000000000000e+03
+3.468329999999999927e+03
+3.451519999999999982e+03
+3.434989999999999782e+03
+3.418679999999999836e+03
+3.402539999999999964e+03
+3.386500000000000000e+03
+3.370519999999999982e+03
+3.354539999999999964e+03
+3.338510000000000218e+03
+3.322409999999999854e+03
+3.306179999999999836e+03
+3.289800000000000182e+03
+3.273210000000000036e+03
+3.256400000000000091e+03
+3.239340000000000146e+03
+3.221989999999999782e+03
+3.204349999999999909e+03
+3.186369999999999891e+03
+3.168050000000000182e+03
+3.149380000000000109e+03
+3.130309999999999945e+03
+3.110860000000000127e+03
+3.091010000000000218e+03
+3.070760000000000218e+03
+3.050099999999999909e+03
+3.029010000000000218e+03
+3.007500000000000000e+03
+2.985559999999999945e+03
+2.963190000000000055e+03
+2.940409999999999854e+03
+2.917190000000000055e+03
+2.893559999999999945e+03
+2.869519999999999982e+03
+2.845059999999999945e+03
+2.820210000000000036e+03
+2.794969999999999800e+03
+2.769340000000000146e+03
+2.743340000000000146e+03
+2.716969999999999800e+03
+2.690239999999999782e+03
+2.663190000000000055e+03
+2.635820000000000164e+03
+2.608130000000000109e+03
+2.580150000000000091e+03
+2.551889999999999873e+03
+2.523349999999999909e+03
+2.494579999999999927e+03
+2.465559999999999945e+03
+2.436340000000000146e+03
+2.406909999999999854e+03
+2.377300000000000182e+03
+2.347519999999999982e+03
+2.317599999999999909e+03
+2.287550000000000182e+03
+2.257380000000000109e+03
+2.227119999999999891e+03
+2.196789999999999964e+03
+2.166409999999999854e+03
+2.135989999999999782e+03
+2.105550000000000182e+03
+2.075110000000000127e+03
+2.044690000000000055e+03
+2.014289999999999964e+03
+1.983960000000000036e+03
+1.953710000000000036e+03
+1.923529999999999973e+03
+1.893460000000000036e+03
+1.863509999999999991e+03
+1.833710000000000036e+03
+1.804049999999999955e+03
+1.774569999999999936e+03
+1.745259999999999991e+03
+1.716180000000000064e+03
+1.687299999999999955e+03
+1.658650000000000091e+03
+1.630250000000000000e+03
+1.602109999999999900e+03
+1.574250000000000000e+03
+1.546670000000000073e+03
+1.519390000000000100e+03
+1.492440000000000055e+03
+1.465799999999999955e+03
+1.439490000000000009e+03
+1.413519999999999982e+03
+1.387910000000000082e+03
+1.362670000000000073e+03
+1.337799999999999955e+03
+1.313309999999999945e+03
+1.289220000000000027e+03
+1.265529999999999973e+03
+1.242240000000000009e+03
+1.219359999999999900e+03
+1.196900000000000091e+03
+1.174880000000000109e+03
+1.153279999999999973e+03
+1.132109999999999900e+03
+1.111380000000000109e+03
+1.091099999999999909e+03
+1.071259999999999991e+03
+1.051869999999999891e+03
+1.032940000000000055e+03
+1.014460000000000036e+03
+9.964370000000000118e+02
+9.788659999999999854e+02
+9.617509999999999764e+02
+9.450940000000000509e+02
+9.288959999999999582e+02
+9.131539999999999964e+02
+8.978579999999999472e+02
+8.830199999999999818e+02
+8.686309999999999718e+02
+8.546960000000000264e+02
+8.412010000000000218e+02
+8.281559999999999491e+02
+8.155470000000000255e+02
+8.033750000000000000e+02
+7.916319999999999482e+02
+7.803170000000000073e+02
+7.694260000000000446e+02
+7.589539999999999509e+02
+7.488949999999999818e+02
+7.392390000000000327e+02
+7.299819999999999709e+02
+7.211159999999999854e+02
+7.126430000000000291e+02
+7.045470000000000255e+02
+6.968310000000000173e+02
+6.894800000000000182e+02
+6.824900000000000091e+02
+6.758569999999999709e+02
+6.695539999999999736e+02
+6.636000000000000227e+02
+6.579759999999999991e+02
+6.526710000000000491e+02
+6.476839999999999691e+02
+6.430069999999999482e+02
+6.386230000000000473e+02
+6.345380000000000109e+02
+6.307219999999999800e+02
+6.271839999999999691e+02
+6.239109999999999445e+02
+6.208949999999999818e+02
+6.181130000000000564e+02
+6.155750000000000455e+02
+6.132609999999999673e+02
+6.111749999999999545e+02
+6.093049999999999500e+02
+6.076230000000000473e+02
+6.061449999999999818e+02
+6.048609999999999900e+02
+6.037649999999999864e+02
+6.028260000000000218e+02
+6.020579999999999927e+02
+6.014349999999999454e+02
+6.009569999999999936e+02
+6.006299999999999955e+02
+6.004329999999999927e+02
+6.003479999999999563e+02
+6.003840000000000146e+02
+6.005249999999999773e+02
+6.007680000000000291e+02
+6.011040000000000418e+02
+6.015270000000000437e+02
+6.020240000000000009e+02
+6.025940000000000509e+02
+6.032309999999999945e+02
+6.039210000000000491e+02
+6.046649999999999636e+02
+6.054539999999999509e+02
+6.062899999999999636e+02
+6.071589999999999918e+02
+6.080460000000000491e+02
+6.089679999999999609e+02
+6.099109999999999445e+02
+6.108600000000000136e+02
+6.118160000000000309e+02
+6.127690000000000055e+02
+6.137329999999999472e+02
+6.146860000000000355e+02
+6.156290000000000191e+02
+6.165549999999999500e+02
+6.174610000000000127e+02
+6.183410000000000082e+02
+6.192000000000000455e+02
+6.200349999999999682e+02
+6.208339999999999463e+02
+6.216090000000000373e+02
+6.223390000000000555e+02
+6.230399999999999636e+02
+6.236839999999999691e+02
+6.242839999999999918e+02
+6.248379999999999654e+02
+6.253460000000000036e+02
+6.258070000000000164e+02
+6.262100000000000364e+02
+6.265629999999999882e+02
+6.268690000000000282e+02
+6.271159999999999854e+02
+6.273060000000000400e+02
+6.274339999999999691e+02
+6.275090000000000146e+02
+6.275199999999999818e+02
+6.274750000000000227e+02
+6.273640000000000327e+02
+6.272019999999999982e+02
+6.269859999999999900e+02
+6.267129999999999654e+02
+6.263740000000000236e+02
+6.259829999999999472e+02
+6.255389999999999873e+02
+6.250420000000000300e+02
+6.244900000000000091e+02
+6.238790000000000191e+02
+6.232110000000000127e+02
+6.224919999999999618e+02
+6.217190000000000509e+02
+6.209020000000000437e+02
+6.200330000000000155e+02
+6.191109999999999900e+02
+6.181499999999999773e+02
+6.171359999999999673e+02
+6.160839999999999463e+02
+6.149829999999999472e+02
+6.138429999999999609e+02
+6.126649999999999636e+02
+6.114560000000000173e+02
+6.102129999999999654e+02
+6.089270000000000209e+02
+6.076250000000000000e+02
+6.062740000000000009e+02
+6.049009999999999536e+02
+6.035019999999999527e+02
+6.020819999999999936e+02
+6.006319999999999482e+02
+5.991689999999999827e+02
+5.976789999999999736e+02
+5.961749999999999545e+02
+5.946499999999999773e+02
diff --git a/tests/data/saxs/trajectory_3_profile.dat b/tests/data/saxs/trajectory_3_profile.dat
new file mode 100644
index 0000000..effca13
--- /dev/null
+++ b/tests/data/saxs/trajectory_3_profile.dat
@@ -0,0 +1,500 @@
+8.128970000000000000e+06
+8.127820000000000000e+06
+8.124460000000000000e+06
+8.118860000000000000e+06
+8.111030000000000000e+06
+8.100960000000000000e+06
+8.088680000000000000e+06
+8.074190000000000000e+06
+8.057500000000000000e+06
+8.038620000000000000e+06
+8.017570000000000000e+06
+7.994370000000000000e+06
+7.969010000000000000e+06
+7.941560000000000000e+06
+7.912050000000000000e+06
+7.880380000000000000e+06
+7.846770000000000000e+06
+7.811090000000000000e+06
+7.773290000000000000e+06
+7.733740000000000000e+06
+7.692170000000000000e+06
+7.648590000000000000e+06
+7.603150000000000000e+06
+7.555830000000000000e+06
+7.506850000000000000e+06
+7.455980000000000000e+06
+7.403430000000000000e+06
+7.349180000000000000e+06
+7.293250000000000000e+06
+7.235750000000000000e+06
+7.176640000000000000e+06
+7.116040000000000000e+06
+7.053900000000000000e+06
+6.990350000000000000e+06
+6.925400000000000000e+06
+6.859120000000000000e+06
+6.791510000000000000e+06
+6.722650000000000000e+06
+6.652600000000000000e+06
+6.581370000000000000e+06
+6.509050000000000000e+06
+6.435670000000000000e+06
+6.361270000000000000e+06
+6.285910000000000000e+06
+6.209630000000000000e+06
+6.132510000000000000e+06
+6.054570000000000000e+06
+5.975880000000000000e+06
+5.896470000000000000e+06
+5.816410000000000000e+06
+5.735750000000000000e+06
+5.654530000000000000e+06
+5.572820000000000000e+06
+5.490650000000000000e+06
+5.408070000000000000e+06
+5.325140000000000000e+06
+5.241910000000000000e+06
+5.158420000000000000e+06
+5.074740000000000000e+06
+4.990890000000000000e+06
+4.906940000000000000e+06
+4.822920000000000000e+06
+4.738890000000000000e+06
+4.654890000000000000e+06
+4.570970000000000000e+06
+4.487180000000000000e+06
+4.403540000000000000e+06
+4.320120000000000000e+06
+4.236940000000000000e+06
+4.154060000000000000e+06
+4.071520000000000000e+06
+3.989340000000000000e+06
+3.907580000000000000e+06
+3.826270000000000000e+06
+3.745440000000000000e+06
+3.665130000000000000e+06
+3.585390000000000000e+06
+3.506230000000000000e+06
+3.427700000000000000e+06
+3.349820000000000000e+06
+3.272630000000000000e+06
+3.196160000000000000e+06
+3.120430000000000000e+06
+3.045470000000000000e+06
+2.971310000000000000e+06
+2.897970000000000000e+06
+2.825480000000000000e+06
+2.753850000000000000e+06
+2.683120000000000000e+06
+2.613300000000000000e+06
+2.544400000000000000e+06
+2.476460000000000000e+06
+2.409480000000000000e+06
+2.343480000000000000e+06
+2.278480000000000000e+06
+2.214490000000000000e+06
+2.151520000000000000e+06
+2.089580000000000000e+06
+2.028690000000000000e+06
+1.968840000000000000e+06
+1.910060000000000000e+06
+1.852350000000000000e+06
+1.795710000000000000e+06
+1.740150000000000000e+06
+1.685680000000000000e+06
+1.632290000000000000e+06
+1.579980000000000000e+06
+1.528770000000000000e+06
+1.478650000000000000e+06
+1.429610000000000000e+06
+1.381670000000000000e+06
+1.334800000000000000e+06
+1.289020000000000000e+06
+1.244320000000000000e+06
+1.200690000000000000e+06
+1.158130000000000000e+06
+1.116630000000000000e+06
+1.076180000000000000e+06
+1.036770000000000000e+06
+9.984100000000000000e+05
+9.610740000000000000e+05
+9.247570000000000000e+05
+8.894490000000000000e+05
+8.551380000000000000e+05
+8.218150000000000000e+05
+7.894660000000000000e+05
+7.580790000000000000e+05
+7.276430000000000000e+05
+6.981430000000000000e+05
+6.695670000000000000e+05
+6.419000000000000000e+05
+6.151280000000000000e+05
+5.892370000000000000e+05
+5.642120000000000000e+05
+5.400370000000000000e+05
+5.166980000000000000e+05
+4.941770000000000000e+05
+4.724610000000000000e+05
+4.515330000000000000e+05
+4.313770000000000000e+05
+4.119760000000000000e+05
+3.933140000000000000e+05
+3.753750000000000000e+05
+3.581430000000000000e+05
+3.416000000000000000e+05
+3.257310000000000000e+05
+3.105180000000000000e+05
+2.959450000000000000e+05
+2.819960000000000000e+05
+2.686530000000000000e+05
+2.559010000000000000e+05
+2.437240000000000000e+05
+2.321050000000000000e+05
+2.210270000000000000e+05
+2.104750000000000000e+05
+2.004340000000000000e+05
+1.908870000000000000e+05
+1.818180000000000000e+05
+1.732120000000000000e+05
+1.650550000000000000e+05
+1.573310000000000000e+05
+1.500240000000000000e+05
+1.431220000000000000e+05
+1.366090000000000000e+05
+1.304700000000000000e+05
+1.246940000000000000e+05
+1.192640000000000000e+05
+1.141680000000000000e+05
+1.093940000000000000e+05
+1.049270000000000000e+05
+1.007560000000000000e+05
+9.686700000000000000e+04
+9.324910000000000582e+04
+8.989030000000000291e+04
+8.677860000000000582e+04
+8.390319999999999709e+04
+8.125269999999999709e+04
+7.881660000000000582e+04
+7.658430000000000291e+04
+7.454569999999999709e+04
+7.269089999999999418e+04
+7.101030000000000291e+04
+6.949450000000000000e+04
+6.813450000000000000e+04
+6.692150000000000000e+04
+6.584710000000000582e+04
+6.490269999999999709e+04
+6.408100000000000000e+04
+6.337380000000000291e+04
+6.277369999999999709e+04
+6.227380000000000291e+04
+6.186709999999999854e+04
+6.154690000000000146e+04
+6.130669999999999709e+04
+6.114059999999999854e+04
+6.104240000000000146e+04
+6.100659999999999854e+04
+6.102759999999999854e+04
+6.110040000000000146e+04
+6.122000000000000000e+04
+6.138140000000000146e+04
+6.158030000000000291e+04
+6.181230000000000291e+04
+6.207340000000000146e+04
+6.235980000000000291e+04
+6.266700000000000000e+04
+6.299240000000000146e+04
+6.333200000000000000e+04
+6.368290000000000146e+04
+6.404180000000000291e+04
+6.440619999999999709e+04
+6.477340000000000146e+04
+6.514090000000000146e+04
+6.550630000000000291e+04
+6.586750000000000000e+04
+6.622210000000000582e+04
+6.656850000000000000e+04
+6.690489999999999418e+04
+6.722950000000000000e+04
+6.754110000000000582e+04
+6.783810000000000582e+04
+6.811919999999999709e+04
+6.838339999999999418e+04
+6.862939999999999418e+04
+6.885650000000000000e+04
+6.906360000000000582e+04
+6.925010000000000582e+04
+6.941539999999999418e+04
+6.955860000000000582e+04
+6.967950000000000000e+04
+6.977789999999999418e+04
+6.985289999999999418e+04
+6.990460000000000582e+04
+6.993280000000000291e+04
+6.993739999999999418e+04
+6.991810000000000582e+04
+6.987500000000000000e+04
+6.980830000000000291e+04
+6.971800000000000000e+04
+6.960400000000000000e+04
+6.946700000000000000e+04
+6.930680000000000291e+04
+6.912419999999999709e+04
+6.891889999999999418e+04
+6.869180000000000291e+04
+6.844269999999999709e+04
+6.817269999999999709e+04
+6.788180000000000291e+04
+6.757069999999999709e+04
+6.723989999999999418e+04
+6.688939999999999418e+04
+6.652060000000000582e+04
+6.613369999999999709e+04
+6.572930000000000291e+04
+6.530809999999999854e+04
+6.487009999999999854e+04
+6.441669999999999709e+04
+6.394819999999999709e+04
+6.346559999999999854e+04
+6.296880000000000291e+04
+6.245909999999999854e+04
+6.193690000000000146e+04
+6.140259999999999854e+04
+6.085730000000000291e+04
+6.030180000000000291e+04
+5.973659999999999854e+04
+5.916230000000000291e+04
+5.857950000000000000e+04
+5.798890000000000146e+04
+5.739119999999999709e+04
+5.678709999999999854e+04
+5.617690000000000146e+04
+5.556150000000000000e+04
+5.494169999999999709e+04
+5.431830000000000291e+04
+5.369130000000000291e+04
+5.306159999999999854e+04
+5.242990000000000146e+04
+5.179669999999999709e+04
+5.116240000000000146e+04
+5.052769999999999709e+04
+4.989309999999999854e+04
+4.925930000000000291e+04
+4.862690000000000146e+04
+4.799630000000000291e+04
+4.736759999999999854e+04
+4.674150000000000000e+04
+4.611919999999999709e+04
+4.550009999999999854e+04
+4.488480000000000291e+04
+4.427400000000000000e+04
+4.366809999999999854e+04
+4.306759999999999854e+04
+4.247269999999999709e+04
+4.188350000000000000e+04
+4.130080000000000291e+04
+4.072469999999999709e+04
+4.015569999999999709e+04
+3.959400000000000000e+04
+3.903980000000000291e+04
+3.849319999999999709e+04
+3.795500000000000000e+04
+3.742480000000000291e+04
+3.690319999999999709e+04
+3.639040000000000146e+04
+3.588650000000000000e+04
+3.539159999999999854e+04
+3.490609999999999854e+04
+3.442990000000000146e+04
+3.396319999999999709e+04
+3.350630000000000291e+04
+3.305900000000000000e+04
+3.262190000000000146e+04
+3.219470000000000073e+04
+3.177709999999999854e+04
+3.136959999999999854e+04
+3.097240000000000146e+04
+3.058540000000000146e+04
+3.020840000000000146e+04
+2.984150000000000000e+04
+2.948500000000000000e+04
+2.913840000000000146e+04
+2.880190000000000146e+04
+2.847540000000000146e+04
+2.815879999999999927e+04
+2.785290000000000146e+04
+2.755629999999999927e+04
+2.726959999999999854e+04
+2.699270000000000073e+04
+2.672540000000000146e+04
+2.646750000000000000e+04
+2.621929999999999927e+04
+2.598020000000000073e+04
+2.575090000000000146e+04
+2.553020000000000073e+04
+2.531850000000000000e+04
+2.511550000000000000e+04
+2.492140000000000146e+04
+2.473590000000000146e+04
+2.455870000000000073e+04
+2.439000000000000000e+04
+2.422909999999999854e+04
+2.407620000000000073e+04
+2.393109999999999854e+04
+2.379359999999999854e+04
+2.366350000000000000e+04
+2.354070000000000073e+04
+2.342500000000000000e+04
+2.331620000000000073e+04
+2.321400000000000000e+04
+2.311850000000000000e+04
+2.302950000000000000e+04
+2.294659999999999854e+04
+2.286970000000000073e+04
+2.279870000000000073e+04
+2.273359999999999854e+04
+2.267379999999999927e+04
+2.261940000000000146e+04
+2.257000000000000000e+04
+2.252570000000000073e+04
+2.248609999999999854e+04
+2.245129999999999927e+04
+2.242070000000000073e+04
+2.239470000000000073e+04
+2.237279999999999927e+04
+2.235459999999999854e+04
+2.234020000000000073e+04
+2.232950000000000000e+04
+2.232229999999999927e+04
+2.231840000000000146e+04
+2.231770000000000073e+04
+2.231940000000000146e+04
+2.232470000000000073e+04
+2.233240000000000146e+04
+2.234270000000000073e+04
+2.235559999999999854e+04
+2.237070000000000073e+04
+2.238790000000000146e+04
+2.240720000000000073e+04
+2.242840000000000146e+04
+2.245109999999999854e+04
+2.247570000000000073e+04
+2.250159999999999854e+04
+2.252909999999999854e+04
+2.255759999999999854e+04
+2.258729999999999927e+04
+2.261840000000000146e+04
+2.265040000000000146e+04
+2.268309999999999854e+04
+2.271659999999999854e+04
+2.275059999999999854e+04
+2.278529999999999927e+04
+2.282040000000000146e+04
+2.285600000000000000e+04
+2.289200000000000000e+04
+2.292809999999999854e+04
+2.296420000000000073e+04
+2.300029999999999927e+04
+2.303670000000000073e+04
+2.307250000000000000e+04
+2.310870000000000073e+04
+2.314440000000000146e+04
+2.318000000000000000e+04
+2.321500000000000000e+04
+2.324970000000000073e+04
+2.328429999999999927e+04
+2.331809999999999854e+04
+2.335120000000000073e+04
+2.338390000000000146e+04
+2.341579999999999927e+04
+2.344720000000000073e+04
+2.347779999999999927e+04
+2.350759999999999854e+04
+2.353659999999999854e+04
+2.356470000000000073e+04
+2.359170000000000073e+04
+2.361800000000000000e+04
+2.364309999999999854e+04
+2.366759999999999854e+04
+2.369100000000000000e+04
+2.371350000000000000e+04
+2.373479999999999927e+04
+2.375520000000000073e+04
+2.377440000000000146e+04
+2.379259999999999854e+04
+2.380970000000000073e+04
+2.382559999999999854e+04
+2.384079999999999927e+04
+2.385459999999999854e+04
+2.386729999999999927e+04
+2.387879999999999927e+04
+2.388909999999999854e+04
+2.389840000000000146e+04
+2.390640000000000146e+04
+2.391320000000000073e+04
+2.391890000000000146e+04
+2.392329999999999927e+04
+2.392659999999999854e+04
+2.392890000000000146e+04
+2.392950000000000000e+04
+2.392920000000000073e+04
+2.392750000000000000e+04
+2.392500000000000000e+04
+2.392190000000000146e+04
+2.391700000000000000e+04
+2.391109999999999854e+04
+2.390400000000000000e+04
+2.389590000000000146e+04
+2.388650000000000000e+04
+2.387629999999999927e+04
+2.386490000000000146e+04
+2.385229999999999927e+04
+2.383870000000000073e+04
+2.382420000000000073e+04
+2.380859999999999854e+04
+2.379200000000000000e+04
+2.377459999999999854e+04
+2.375590000000000146e+04
+2.373620000000000073e+04
+2.371559999999999854e+04
+2.369429999999999927e+04
+2.367190000000000146e+04
+2.364900000000000000e+04
+2.362470000000000073e+04
+2.359970000000000073e+04
+2.357370000000000073e+04
+2.354670000000000073e+04
+2.351890000000000146e+04
+2.349029999999999927e+04
+2.346079999999999927e+04
+2.343059999999999854e+04
+2.339979999999999927e+04
+2.336800000000000000e+04
+2.333529999999999927e+04
+2.330200000000000000e+04
+2.326790000000000146e+04
+2.323309999999999854e+04
+2.319750000000000000e+04
+2.316120000000000073e+04
+2.312420000000000073e+04
+2.308659999999999854e+04
+2.304820000000000073e+04
+2.300909999999999854e+04
+2.296929999999999927e+04
+2.292900000000000000e+04
+2.288790000000000146e+04
+2.284629999999999927e+04
+2.280390000000000146e+04
+2.276079999999999927e+04
+2.271720000000000073e+04
+2.267300000000000000e+04
+2.262820000000000073e+04
+2.258290000000000146e+04
+2.253679999999999927e+04
+2.249040000000000146e+04
+2.244300000000000000e+04
+2.239509999999999854e+04
+2.234659999999999854e+04
+2.229750000000000000e+04
+2.224800000000000000e+04
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 14870ea..cfe443b 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,7 +1,11 @@
 import os
 import pytest
+import numpy as np
+import MDAnalysis as mda
+import shutil
 
 from idpflex import utils
+from idpflex.properties import SaxsProperty, SansProperty
 
 
 def test_write_frame(trajectory_benchmark):
@@ -12,5 +16,21 @@ def test_write_frame(trajectory_benchmark):
     os.remove('test.pdb')
 
 
+@pytest.mark.skipif(shutil.which('cryson') is None
+                    or shutil.which('crysol') is None, reason='Needs cryson')
+def test_generate_trajectory_profiles(saxs_benchmark, sans_benchmark):
+    saxs_ref = np.loadtxt(saxs_benchmark['frame_profile'])
+    sans_ref = np.loadtxt(sans_benchmark['frame_profile'])
+    universe = mda.Universe(saxs_benchmark['crysol_pdb'],
+                            saxs_benchmark['crysol_xtc'])
+    protein = universe.select_atoms('protein')
+    saxs_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SaxsProperty)[3].profile
+    sans_prof = utils.generate_trajectory_profiles(protein, range(4),
+                                                   SansProperty)[3].profile
+    np.testing.assert_array_almost_equal(saxs_ref, saxs_prof)
+    np.testing.assert_array_almost_equal(sans_ref, sans_prof)
+
+
 if __name__ == '__main__':
     pytest.main()

From 4daacd0fbfc839046e3954f85308fd81aed90509 Mon Sep 17 00:00:00 2001
From: Connor Pigg <cpigg2@illinois.edu>
Date: Wed, 12 Jun 2019 12:04:43 -0400
Subject: [PATCH 6/6] Cache pip dependencies.

---
 .travis.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 6cccd2a..cfa010d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,8 @@ python:
   - "3.7"
   - "3.6"
 
+cache: pip
+
 env: PYTHONPATH=$PYTHONPATH:$TRAVIS_BUILD_DIR/tests
 
 before_install: