Open kain88-de opened 9 years ago
Just fyi, Universe doesn't currently have a len (it would be unclear if it meant len(trajectory) or len(atoms))
I also don't like putting type checks on things like this. Ideally it should work with any object that has all the required attributes, AtomGroup or not. Duck typing etc etc
Using atoms=atomgroup
saves a wee bit of typing (instead of n_atoms=len(ag)
) and is conceptually nice. So yes, why not? (We'll just have to keep n_atoms
around for a while in parallel until we get to the next API break...)
I think in this instance one cannot get away with simple duck typing (i.e. you can't just ask for len(obj)
). However, len(obj.atoms)
should always give you the right answer (unless it's an int
).
it seems that mda dev prefer to use OO. I myself prefer to use verb to perform action.
In pytraj
import pytraj as pt
traj = pt.load('traj.nc', 'prmtop')
pt.save('new_name.dcd', traj)
# with mask
pt.save('new_name.dcd', traj(mask='@CA'))
(disclaimer: my first language is PASCAL :D).
it seems that mda dev prefer to use OO.
@hainm Yes. :)
@kain88-de I'm in favor for having the proposed functionality. Let's come to a conclusion here to either implement in the future or close the issue.
OK then we can go for this in the future.
hello all, I am interested in solving this issue as much as i understood we need to take atoms as argument in coordinates/core.py int function writer instead of n_atoms and this atom argument can be of 3 type 1. atomgroup 2. universe 3. int. and in writer class we have to extract n_atoms by code given by @kain88-de or slight modfication of code. Thanks any inputs on this will be appreciated :)
First we need to make sure that all writers use the same API. This means they all should use the same base tests see, #516.
In #511 i noticed that a more natural way of using the writers would be to have an
atoms
arguments which can be of type (Universe, AtomGroup, int). Allowing for usages like thisImplementing this is easy for each writer class.
But since this is an API change it is better if we discuss is first. And I think we should wait with it until #516 is completed, then we can make the change on all writers and the same time.