示例#1
0
    def addCalphaBonds(self):
        '''
This adds the Calpha bonds for all the residues in a chain. If there is
a gap in the sequence of residues, this will not place a C-alpha 
bond.setAtom0Ix--one doesn't want a bond between the 97th and 103rd 
residue.
    '''
        cnt = 0
        try:
            viewer = Chain.getViewer()
        except:
            print 'Error: No viewer is set for Chain!'
            return
        for res0num in self.residueRange():
            atom0 = self[res0num].getAtom('CA')
            if not atom0:
                continue
            if res0num + 1 in self.residueRange():
                atom1 = self[res0num + 1].getAtom('CA')
                if not atom1:
                    continue
                bond = PDBBond()
                bond.setAtom0Ix(atom0.getHashKey())
                bond.setAtom1Ix(atom1.getHashKey())
                viewer.renderer.addBond(bond)
                self.bonds.append((res0num, res0num + 1))
                cnt = cnt + 1
示例#2
0
    def addSheetBonds(self):
        try:
            viewer = Chain.getViewer()
        except:
            print 'Error: No viewer is set for Chain!'
            return
        for sheet in self.sheets.values():
            for bond in sheet.bonds:
                atom0 = self[bond[0]].getAtom('CA')
                atom1 = self[bond[1]].getAtom('CA')

                bond = PDBBond()
                bond.setAtom0Ix(atom0.getHashKey())
                bond.setAtom1Ix(atom1.getHashKey())
                viewer.renderer.addBond(bond)
    def redo(self):
        """
In addition to being called to redo an action, this is called the first
time the action occurs.
        """
        raw = PDBAtom(self.currentChainModel.getPdbID(),
                      self.currentChainModel.getChainID(), self.resSeqNum,
                      'CA')
        raw.setPosition(self.chosenCoordinates)
        atom = self.viewer.renderer.addAtom(raw)
        self.currentChainModel[self.resSeqNum].addAtomObject(atom)
        self.currentChainModel[self.resSeqNum].setCAlphaColorToDefault()
        bondBefore = None
        bondAfter = None
        if self.resSeqNum - 1 in self.currentChainModel.residueRange():
            prevCAlpha = self.currentChainModel[self.resSeqNum -
                                                1].getAtom('CA')
            if prevCAlpha:
                bondBefore = PDBBond()
                bondBefore.setAtom0Ix(prevCAlpha.getHashKey())
                bondBefore.setAtom1Ix(atom.getHashKey())
        if self.resSeqNum + 1 in self.currentChainModel.residueRange():
            nextCAlpha = self.currentChainModel[self.resSeqNum +
                                                1].getAtom('CA')
            if nextCAlpha:
                bondAfter = PDBBond()
                bondAfter.setAtom0Ix(nextCAlpha.getHashKey())
                bondAfter.setAtom1Ix(atom.getHashKey())

        if bondBefore:
            self.viewer.renderer.addBond(bondBefore)
        if bondAfter:
            self.viewer.renderer.addBond(bondAfter)

        self.viewer.emitModelChanged()
        self.structureEditor.atomJustAdded = atom

        if self.structureEditor.atomicBackwardRadioButton.isChecked():
            self.structureEditor.atomPrevButtonPress()
        elif self.structureEditor.atomicForwardRadioButton.isChecked():
            self.structureEditor.atomNextButtonPress()
示例#4
0
    def redo(self):

        self.helix = Helix(self.currentChainModel, self.predHelix.serialNo,
                           self.predHelix.label, self.startIndex,
                           self.stopIndex)
        self.currentChainModel.addHelix(self.predHelix.serialNo, self.helix)
        self.helix.setAxisPoints(self.coord1, self.coord2)

        helixCoordList = helixEndpointsToCAlphaPositions(
            self.coord1, self.coord2)
        '''
        #To see the ends of the helical axis as green and red atoms
        startAtom = PDBAtom('AAAA', 'A', 100000, 'CA')
        startAtom.setPosition(Vector3DFloat(*coord1))
        startAtom.setColor(0, 1, 0, 1)
        startAtom = self.CAlphaViewer.renderer.addAtom(startAtom)
        stopAtom = startAtom = PDBAtom('AAAA', 'A', 100001, 'CA')
        stopAtom.setPosition(Vector3DFloat(*coord2))
        stopAtom.setColor(1, 0, 0, 1)        
        stopAtom = self.CAlphaViewer.renderer.addAtom(stopAtom)
        '''

        for i in range(
                min(len(helixCoordList),
                    self.stopIndex - self.startIndex + 1)):
            pos = helixCoordList[i]
            residue = self.currentChainModel[self.startIndex + i]
            rawAtom = residue.addAtom('CA', pos[0], pos[1], pos[2], 'C')
            atom = self.CAlphaViewer.renderer.addAtom(rawAtom)
            residue.addAtomObject(atom)
            atom.setSelected(True)
            try:
                prevAtom = self.currentChainModel[self.startIndex + i -
                                                  1].getAtom('CA')
                bond = PDBBond()
                bond.setAtom0Ix(prevAtom.getHashKey())
                bond.setAtom1Ix(atom.getHashKey())
                self.CAlphaViewer.renderer.addBond(bond)
            except (KeyError, IndexError, AttributeError):
                continue

        try:
            nextAtom = self.currentChainModel[self.startIndex +
                                              len(helixCoordList)]
            bond = PDBBond()
            bond.setAtom0Ix(atom.getHashKey())
            bond.setAtom1Ix(nextAtom.getHashKey())
            self.CAlphaViewer.renderer.addBond(bond)
        except (KeyError, IndexError, AttributeError):
            pass

        self.currentChainModel.setSelection(
            newSelection=range(self.startIndex, 1 + self.stopIndex))

        if not self.CAlphaViewer.loaded:
            self.CAlphaViewer.loaded = True
            self.CAlphaViewer.emitModelLoaded()
        else:
            self.CAlphaViewer.emitModelChanged()
示例#5
0
rawAtom.setPosition(Vector3DFloat(-.5, -0.5, -0.5))
rawAtom = cAlphaViewer.renderer.addAtom(
    rawAtom
)  #A new PDBAtom is returned by this function, and rawAtom needs to refer to it

# Instantiate an Second Atom
rawAtom2 = PDBAtom('AAAA', 'A', 2, 'CA')
rawAtom2.setPosition(Vector3DFloat(.5, 0.5, 0.5))
rawAtom2 = cAlphaViewer.renderer.addAtom(rawAtom2)

# Confirm that these accessor functions are working
key = rawAtom2.getHashKey()
atom = cAlphaViewer.renderer.getAtom(key)
print atom.getPDBId()
print atom.getChainId()

# Instantiate a Bond between Atoms
bond = PDBBond()
bond.setAtom0Ix(rawAtom.getHashKey())
bond.setAtom1Ix(rawAtom2.getHashKey())
cAlphaViewer.renderer.addBond(bond)

# I don't understand this code, but first 3 lines are required, last two are not
if not cAlphaViewer.loaded:
    cAlphaViewer.loaded = True
    cAlphaViewer.emitModelLoaded()
#cAlphaViewer.dirty = True
#cAlphaViewer.emitModelChanged()

sys.exit(app.exec_())
示例#6
0
 def addSideChainBonds(self):
     cnt = 0
     try:
         viewer = Chain.getViewer()
     except:
         print 'Error: No viewer is set for Chain!'
         return
     for i in self.residueRange():
         if self[i].symbol3 in self.sideChainConnectivity:
             for j in range(len(
                     self.sideChainConnectivity[self[i].symbol3])):
                 atom0 = self[i].getAtom(
                     self.sideChainConnectivity[self[i].symbol3][j][0])
                 atom1 = self[i].getAtom(
                     self.sideChainConnectivity[self[i].symbol3][j][1])
                 if atom0 and atom1:
                     bond = PDBBond()
                     bond.setAtom0Ix(atom0.getHashKey())
                     bond.setAtom1Ix(atom1.getHashKey())
                     viewer.renderer.addSideChainBond(bond)
         # Connecting the C of this residue to the N of the next residue
         if i + 1 in self.residueRange():
             atom0 = self[i].getAtom('C')
             atom1 = self[i + 1].getAtom('N')
             if atom0 and atom1:
                 bond = PDBBond()
                 bond.setAtom0Ix(atom0.getHashKey())
                 bond.setAtom1Ix(atom1.getHashKey())
                 viewer.renderer.addSideChainBond(bond)
示例#7
0
# Instantiate a Second Atom
rawAtom2 = PDBAtom('AAAA', 'A', 2, 'CA')
rawAtom2.setPosition(Vector3DFloat(*stopPos))
rawAtom2.setAtomRadius(2)
rawAtom2.setColor(1, 0, 0, 1)
rawAtom2 = cAlphaViewer.renderer.addAtom(rawAtom2)

# Get coordinates for helix with axis starting and ending at startPos and stopPos
coordList = helixEndpointsToCAlphaPositions(startPos, stopPos)
atomList = []

# Create helix atoms and bonds
for i in xrange(len(coordList)):
    raw = PDBAtom('AAAA', 'A', i + 3, 'CA')
    raw.setPosition(
        Vector3DFloat(coordList[i][0], coordList[i][1], coordList[i][2]))
    atomList.append(cAlphaViewer.renderer.addAtom(raw))
    if i != 0:
        bond = PDBBond()
        bond.setAtom0Ix(atomList[-2].getHashKey())
        bond.setAtom1Ix(atomList[-1].getHashKey())
        cAlphaViewer.renderer.addBond(bond)

if not cAlphaViewer.loaded:
    cAlphaViewer.loaded = True
    cAlphaViewer.emitModelLoaded()

cAlphaViewer.emitViewerSetCenter()

sys.exit(app.exec_())
    def setLoopAtoms(self, startIndex, endIndex):

        self.engine.clearAtomList()
        self.engine.clearCurrentPath()

        for i in range(startIndex, endIndex + 1):
            if (i in self.chain.residueRange()):
                atom = self.chain[i].getAtom('CA')
                if (not atom):
                    raw = PDBAtom(self.chain.getPdbID(),
                                  self.chain.getChainID(), i, 'CA')
                    raw.setPosition(Vector3DFloat(0, 0, 0))
                    atom = self.calphaViewer.renderer.addAtom(raw)
                    atom.setVisible(False)
                    print atom
                    self.chain[i].addAtomObject(atom)
                    self.chain[i].setCAlphaColorToDefault()
                    bondBefore = None
                    bondAfter = None
                    if i - 1 in self.chain.residueRange():
                        prevCAlpha = self.chain[i - 1].getAtom('CA')
                        if prevCAlpha:
                            print "adding a bond before"
                            bondBefore = PDBBond()
                            bondBefore.setAtom0Ix(prevCAlpha.getHashKey())
                            bondBefore.setAtom1Ix(atom.getHashKey())
                    if i + 1 in self.chain.residueRange():
                        nextCAlpha = self.chain[i + 1].getAtom('CA')
                        if nextCAlpha:
                            print "adding a bond after"
                            bondAfter = PDBBond()
                            bondAfter.setAtom0Ix(nextCAlpha.getHashKey())
                            bondAfter.setAtom1Ix(atom.getHashKey())

                    if bondBefore:
                        self.calphaViewer.renderer.addBond(bondBefore)
                    if bondAfter:
                        self.calphaViewer.renderer.addBond(bondAfter)

                self.engine.addAtom(atom.getHashKey())

        if not self.calphaViewer.loaded:
            self.calphaViewer.loaded = True
            self.calphaViewer.emitModelLoaded()
        else:
            self.calphaViewer.emitModelChanged()