changeset 2:589f8ef21e58 draft default tip

"planemo upload for repository https://github.com/galaxycomputationalchemistry/galaxy-tools-compchem/ commit f1c3c88c7395f2e84cbc533199406aadb79c5c07"
author chemteam
date Fri, 13 Nov 2020 19:44:09 +0000
parents 8f6ad93973cb
children
files extract_rmsd.py extract_rmsd.xml
diffstat 2 files changed, 15 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/extract_rmsd.py	Wed Oct 28 21:41:04 2020 +0000
+++ b/extract_rmsd.py	Fri Nov 13 19:44:09 2020 +0000
@@ -36,29 +36,29 @@
 
     no_t = len(traj_file_list)
 
-    data = np.zeros((no_t, no_t,
-                    int((end - start)/step + ((end - start) % step > 0))))
-
-    # load files
-    universes = {}
+    # hard to find array size before loading files
+    universe_coordinate_data = []
 
     for traj in range(no_t):
         # We no longer align here, users should do this themselves.
-        universes[traj] = m.Universe(str_file_list[traj], traj_file_list[traj],
-                                     format=traj_format,
-                                     topology_format=str_format)
+        u = m.Universe(str_file_list[traj], traj_file_list[traj],
+                       format=traj_format, topology_format=str_format)
+        u.transfer_to_memory()
+        grp = u.select_atoms(group).universe
+        coordinates = grp.trajectory.coordinate_array[start:end:step]
+        universe_coordinate_data.append(coordinates)
 
+    universe_coordinate_data = np.array(universe_coordinate_data)
     print("All trajs loaded by MDAnalysis")
+    data = np.zeros((no_t, no_t, universe_coordinate_data.shape[1]))
 
     # calculate differences
     for traj1 in range(no_t):
         print("Calculating differences for traj {}".format(traj1))
         for traj2 in range(traj1):
             for frame in range(data.shape[2]):
-                universes[traj1].trajectory[frame]
-                universes[traj2].trajectory[frame]
-                A = universes[traj1].select_atoms(group).positions
-                B = universes[traj2].select_atoms(group).positions
+                A = universe_coordinate_data[traj1, frame]
+                B = universe_coordinate_data[traj2, frame]
                 r = rms.rmsd(A, B)
                 data[traj1, traj2, frame] = r
                 data[traj2, traj1, frame] = r
@@ -90,7 +90,6 @@
     parser.add_argument('--step', type=int,
                         help="Frame sampling frequency for RMSD calculation")
     args = parser.parse_args()
-
     calc_rmsd(args.strs, args.trajs, args.str_format,
               args.traj_format, args.outfile,
               args.group, args.start, args.end, args.step)
--- a/extract_rmsd.xml	Wed Oct 28 21:41:04 2020 +0000
+++ b/extract_rmsd.xml	Fri Nov 13 19:44:09 2020 +0000
@@ -2,7 +2,7 @@
     <description>from MD ensemble with MDAnalysis</description>
     <macros>
         <import>macros.xml</import>
-        <token name="@GALAXY_VERSION@">1</token>
+        <token name="@GALAXY_VERSION@">2</token>
     </macros>
     <expand macro="requirements"/>
     <command detect_errors="exit_code"><![CDATA[
@@ -57,7 +57,7 @@
             <param name="step" value="1" />
             <output name="output"> 
                 <assert_contents>
-                    <has_text text="0.0" n="20"/>
+                    <has_text text="0.0" n="60"/>
                     <has_size value="1126" />
                     <has_n_lines n="74" />
                 </assert_contents>
@@ -101,4 +101,4 @@
 
     ]]></help>
     <expand macro="citations" />
-</tool>
\ No newline at end of file
+</tool>