Example #1
0
def test_rep_attributes(file_3nob):
    m = molecule.load("mae", file_3nob)

    r = molrep.addrep(style="NewCartoon",
                      color="ResID",
                      selection="protein",
                      material="AOShiny",
                      molid=m)

    # Query name
    assert molrep.get_repname(molid=m, rep=r) == "rep1"
    with pytest.raises(ValueError):
        molrep.get_repname(m + 1, 0)
    with pytest.raises(ValueError):
        molrep.get_repname(m, r + 1)

    # Query ID
    assert molrep.repindex(m, "rep1") == r
    assert molrep.repindex(m, "nonexistent") is None
    with pytest.raises(ValueError):
        molrep.repindex(m + 1, "wrong")

    # Query style
    assert molrep.get_style(m, r) == "NewCartoon"
    with pytest.raises(ValueError):
        molrep.get_style(m + 1, 0)
    with pytest.raises(ValueError):
        molrep.get_style(m, r + 1)

    # Query selection
    assert molrep.get_selection(m, r) == "protein"
    with pytest.raises(ValueError):
        molrep.get_selection(m + 1, 0)
    with pytest.raises(ValueError):
        molrep.get_selection(m, r + 1)

    # Query color
    assert molrep.get_color(m, r) == "ResID"
    with pytest.raises(ValueError):
        molrep.get_color(m + 1, 0)
    with pytest.raises(ValueError):
        molrep.get_color(m, r + 1)

    # Query material
    assert molrep.get_material(m, r) == "AOShiny"
    with pytest.raises(ValueError):
        molrep.get_material(m + 1, 0)
    with pytest.raises(ValueError):
        molrep.get_material(m, r + 1)

    molecule.delete(m)
Example #2
0
def test_rep_attributes(file_3nob):
    m = molecule.load("mae", file_3nob)

    r = molrep.addrep(style="NewCartoon", color="ResID", selection="protein",
                      material="AOShiny", molid=m)

    # Query name
    assert molrep.get_repname(molid=m, rep=r) == "rep1"
    with pytest.raises(ValueError):
        molrep.get_repname(m+1, 0)
    with pytest.raises(ValueError):
        molrep.get_repname(m, r+1)

    # Query ID
    assert molrep.repindex(m, "rep1") == r
    assert molrep.repindex(m, "nonexistent") is None
    with pytest.raises(ValueError):
        molrep.repindex(m+1, "wrong")

    # Query style
    assert molrep.get_style(m, r) == "NewCartoon"
    with pytest.raises(ValueError):
        molrep.get_style(m+1, 0)
    with pytest.raises(ValueError):
        molrep.get_style(m, r+1)

    # Query selection
    assert molrep.get_selection(m, r) == "protein"
    with pytest.raises(ValueError):
        molrep.get_selection(m+1, 0)
    with pytest.raises(ValueError):
        molrep.get_selection(m, r+1)

    # Query color
    assert molrep.get_color(m, r) == "ResID"
    with pytest.raises(ValueError):
        molrep.get_color(m+1, 0)
    with pytest.raises(ValueError):
        molrep.get_color(m, r+1)

    # Query material
    assert molrep.get_material(m, r) == "AOShiny"
    with pytest.raises(ValueError):
        molrep.get_material(m+1, 0)
    with pytest.raises(ValueError):
        molrep.get_material(m, r+1)

    molecule.delete(m)
Example #3
0
 def changeMaterial(self, material):
   """ Change the material for the rep to 'material'."""
   for id,name in self.molecules.items():
     repid = molrep.repindex(id, name)
     if not molrep.modrep(id, repid, material=material):
       raise ValueError("Invalid material'%s'" % material)
   self.material = str(material)
Example #4
0
 def changeSelection(self, selection):
   """ Change the atom selection of the rep to 'selection'."""
   for id,name in self.molecules.items():
     repid = molrep.repindex(id, name)
     if not molrep.modrep(id, repid, sel=selection):
       raise ValueError("Invalid selection '%s'" % selection)
   self.selection = str(selection)
Example #5
0
 def changeColor(self, color):
   """ Change the coloring method the rep to 'color'."""
   for id,name in self.molecules.items():
     repid = molrep.repindex(id, name)
     if not molrep.modrep(id, repid, color=color):
       raise ValueError("Invalid color '%s'" % color)
   self.color = str(color)
Example #6
0
 def changeStyle(self, style):
   """ Change the draw style of the rep to 'style'."""
   for id,name in self.molecules.items():
     repid = molrep.repindex(id, name)
     if not molrep.modrep(id, repid, style=style):
       raise ValueError("Invalid style '%s'" % style)
   self.style = str(style)
Example #7
0
 def delRep(self, rep):
   """ Remove the given rep from the molecule."""
   repname = rep.remove_molecule(self.id)
   if repname:
     repid = molrep.repindex(self.id, repname)
     if repid >= 0:
       molrep.delrep(self.id, repid)
Example #8
0
  def autoUpdate(self, rep, onoff = None):
    """ Get/set whether this rep should be recalculated whenever the coordinate
    frame changes for this molecule. """

    # Get the repid for this rep
    try:
      name = rep.molecules[self.id]
    except KeyError:
      raise ValueError("This molecule does not contain this rep.")
    repid = molrep.repindex(self.id, name)
    if onoff is None:
      return molrep.get_autoupdate(self.id, repid)
    molrep.set_autoupdate(self.id, repid, onoff)
    return self