You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Right now the user would need to write a custom function to read the final frame of a Cassandra trajectory.
Describe the solution you'd like
An API that looks like:
importmosdef_cassandraasmc
...
mc.load_final_frame(system, trajectory_filename)
mc.load_frame(system, trajectory_filename, frame_number) # alternative
** Open questions **
What data structure should this return? mbuild.Compound? parmed.Structure? gmso.Topology?
The Compound is easiest to implement, but if we are going to require the system object for this function call, then perhaps we can return the full system/topology?
Describe alternatives you've considered
Another option is to create a to_mdtraj function -- but this requires adding mdtraj as a dependency.
The text was updated successfully, but these errors were encountered:
defload_final_xyz_frame(fname):
"""Return the final frame of a Cassandra .xyz file as an mbuild.Compound Assumes there is a .H file with the same name. E.g., if the .xyz file is 'equil.out.xyz', there should also be an 'equil.out.H' containing the box information. Arguments --------- fname : str path to the xyz file Returns ------- mbuild.Compound the mbuild.Compound for the final frame """ifnotisinstance(fname, str):
raiseTypeError("'fname' must be a string")
iffname[-4:] ==".xyz":
fname=fname[:-4]
data= []
withopen(fname+".xyz") asf:
forlineinf:
data.append(line.strip().split())
foriline, lineinenumerate(data):
iflen(line) >0:
ifline[0] =="MC_STEP:":
natom_line=iline-1final_frame=data[natom_line+2 :]
natoms=int(data[natom_line][0])
withopen(fname+"-final.xyz", "w") asf:
f.write(f"{natoms}\nAtoms\n")
forcoordinfinal_frame:
f.write(
"{}\t{}\t{}\t{}\n".format(
coord[0], coord[1], coord[2], coord[3],
)
)
data= []
withopen(fname+".H") asf:
forlineinf:
data.append(line.strip().split())
nspecies=int(data[-1][0])
box_matrix=np.asarray(
data[-(nspecies+5) : -(nspecies+2)], dtype=np.float32
)
assertbox_matrix.shape== (3, 3)
ifnp.count_nonzero(box_matrix-np.diag(np.diagonal(box_matrix))) >0:
raiseValueError("Only orthogonal boxes are currently supported")
# If all is well load in the final frameframe=mbuild.load(fname+"-final.xyz")
# mbuild.Compounds use nanometers!frame.periodicity=np.diagonal(box_matrix/10.0)
returnframe
Is your feature request related to a problem? Please describe.
Right now the user would need to write a custom function to read the final frame of a Cassandra trajectory.
Describe the solution you'd like
An API that looks like:
** Open questions **
What data structure should this return?
mbuild.Compound
?parmed.Structure
?gmso.Topology
?The
Compound
is easiest to implement, but if we are going to require the system object for this function call, then perhaps we can return the full system/topology?Describe alternatives you've considered
Another option is to create a
to_mdtraj
function -- but this requires addingmdtraj
as a dependency.The text was updated successfully, but these errors were encountered: