Coarse-graining a trajectory

The Coarse Grainer is a scriptable tool in Materials Studio to convert a molecular model to a bead model.

Although the tool works with single structures (xsd), with the latest trajectory API in Materials Studio 5.0, it is straightforward to coarsegrain trajectories (xtd) too:

 sub CoarseGrainTrajectory{     my (\\\$xtd) = @_;     my \\\$trj = \\\$xtd->Trajectory;     my \\\$xtdCG = Documents->New(\\\$xtd->Name . " CG.xtd");     my \\\$trjCG = \\\$xtdCG->Trajectory;     my \\\$cg = Tools->CoarseGrainer->CoarseGrain;     my \\\$typingDoc = Documents->New("Bead Typing.std");     for (my \\\$frame = 1; \\\$frame <= \\\$trj->NumFrames; ++\\\$frame)     {          \\\$trj->CurrentFrame = \\\$frame;                    \\\$cg->UpdateTypingDocument(\\\$xtd, \\\$typingDoc) if(\\\$frame == 1);          my \\\$frameCG = \\\$cg->Build(\\\$xtd, \\\$typingDoc);          \\\$trjCG->AppendFramesFrom(\\\$frameCG->Structure);          \\\$frameCG->Structure->Delete;     }     return \\\$xtdCG;}

Attached is an example using this subroutine, coarse graining a dynamics trajectory of PDMS. The example uses bead type names A,B,C,... for ease of reference. The trajectory can be analyzed in Mesocite.

Hope you find it useful.

Reinier