def setup(self, args): protsel = self.processor.universe.select_atoms(args.pmask) self.uselib = args.uselib if self.uselib == "no": self.atm2 = protsel.select_atoms("name " + args.atoms[1]) self.atm1 = protsel.select_atoms("name " + args.atoms[0] + " and byres name " + args.atoms[1]) elif self.uselib in resanallib: lib = resanallib[self.uselib] atm1 = [] atm2 = [] for res in self.processor.universe.select_atoms( "protein").residues: if res.name not in lib: continue for atompairs in lib[res.name]: atm1.append(res[atompairs[0]]) atm2.append(res[atompairs[1]]) self.atm2 = AtomGroup.AtomGroup(atm2) self.atm1 = AtomGroup.AtomGroup(atm1) self.mat = np.zeros([len(self.atm1), len(self.atm1)]) self.s2list = [] self.outname = args.out self.dosubsample = True self.resoffset = args.resoffset
def test_merge_without_topology(self): # This shouldn't have topology as we merged single atoms ag1 = AtomGroup([self.u.atoms[1]]) ag2 = AtomGroup([self.u.atoms[10]]) u2 = MDAnalysis.Merge(ag1, ag2) assert_(len(u2.atoms) == 2) assert_(len(u2.bonds) == 0) assert_(len(u2.angles) == 0) assert_(len(u2.dihedrals) == 0) assert_(len(u2.impropers) == 0)
def test_emptyAG_ValueError(self): a = AtomGroup([]) b = AtomGroup([]) assert_raises(ValueError, Merge, a, b)
def test_pickle_unpickle_empty(self): """Test that an empty AtomGroup can be pickled/unpickled (Issue 293)""" ag = AtomGroup([]) pickle_str = cPickle.dumps(ag, protocol=cPickle.HIGHEST_PROTOCOL) newag = cPickle.loads(pickle_str) assert_equal(len(newag), 0)