# Copyright 2008 Nanorex, Inc. See LICENSE file for details. """ PeptideGenerator.py Peptide Generator can generate short polypeptide chains of arbitrarily choosen sequence and secondary structure. @author: Piotr @version: $Id$ @copyright: 2008 Nanorex, Inc. See LICENSE file for details. @see http://www.nanoengineer-1.net/mediawiki/index.php?title=Peptide_generator_dialog for notes about what's going on here. """ import foundation.env as env from commands.InsertPeptide.PeptideGeneratorPropertyManager import PeptideGeneratorPropertyManager from command_support.GeneratorBaseClass import GeneratorBaseClass from utilities.Log import greenmsg from model.chem import Atom from model.chunk import Chunk from model.bonds import bond_atoms from geometry.NeighborhoodGenerator import NeighborhoodGenerator from model.bond_constants import atoms_are_bonded from model.bond_constants import V_SINGLE, V_DOUBLE, V_AROMATIC from operations.bonds_from_atoms import inferBonds from Numeric import zeros, array, sqrt, pi, sin, cos, dot, Float from geometry.VQT import vlen, cross, norm, V # Internal coordinate sets for amino acids # Converted from AMBER all_amino94.in file # Fixed a few issues: conformation of phenylalanine, connectivity of serine. # Beware of proline - it needs to be handled in a different way. ALA_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp3", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB1", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 9, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 180.000 ), ( 10, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 11, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 12, "O ", "O", "sp2", 11, 5, 3, 1.229, 120.500, 0.000 ), ] GLY_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA2", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "HA3", "H", "", 5, 3, 2, 1.090, 109.500, 60.000 ), ( 8, "C ", "C", "sp2", 5, 3, 2, 1.522, 110.400, 180.000 ), ( 9, "O ", "O", "sp2", 8, 5, 3, 1.229, 120.500, 0.000 ) ] SER_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "OG ", "O", "sp3", 7, 5, 3, 1.430, 109.470, 180.000 ), ( 11, "HG ", "H", "", 10, 7, 5, 0.960, 109.470, 180.000 ), ( 12, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 13, "O ", "O", "sp2", 12, 5, 3, 1.229, 120.500, 0.000 ), ] PHE_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2a", 7, 5, 3, 1.510, 115.000, 180.000 ), ( 11, "CD1", "C", "sp2a", 10, 7, 5, 1.400, 120.000, 180.000 ), ( 12, "HD1", "H", "", 11, 10, 7, 1.090, 120.000, 0.000 ), ( 13, "CE1", "C", "sp2a", 11, 10, 7, 1.400, 120.000, 180.000 ), ( 14, "HE1", "H", "", 13, 11, 10, 1.090, 120.000, 180.000 ), ( 15, "CZ ", "C", "sp2a", 13, 11, 10, 1.400, 120.000, 0.000 ), ( 16, "HZ ", "H", "", 15, 13, 11, 1.090, 120.000, 180.000 ), ( 17, "CE2", "C", "sp2a", 15, 13, 11, 1.400, 120.000, 0.000 ), ( 18, "HE2", "H", "", 17, 15, 13, 1.090, 120.000, 180.000 ), ( 19, "CD2", "C", "sp2a", 17, 15, 13, 1.400, 120.000, 0.000 ), ( 20, "HD2", "H", "", 19, 17, 15, 1.090, 120.000, 180.000 ), ( 21, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 22, "O ", "O", "sp2", 21, 5, 3, 1.229, 120.500, 0.000 ), ] GLU_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.510, 109.470, 180.000 ), ( 11, "HG2", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "HG3", "H", "", 10, 7, 5, 1.090, 109.500, 60.000 ), ( 13, "CD ", "C", "sp2", 10, 7, 5, 1.527, 109.470, 180.000 ), ( 14, "OE1", "O", "sp2", 13, 10, 7, 1.260, 117.200, 90.000 ), ( 15, "OE2", "O", "sp3", 13, 10, 7, 1.260, 117.200, 270.000 ), ( 16, "HE2", "H", "", 15, 13, 10, 0.960, 109.500, 180.000 ), ( 17, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 18, "O ", "O", "sp2", 17, 5, 3, 1.229, 120.500, 0.000 ), ] PRO_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.337, 117.000, 180.000 ), ( 4, "CD ", "C", "sp3", 3, 2, 1, 1.458, 126.100, 356.100 ), ( 5, "HD2", "H", "", 4, 3, 2, 1.090, 109.500, 80.000 ), ( 6, "HD3", "H", "", 4, 3, 2, 1.090, 109.500, 320.000 ), ( 7, "CG ", "C", "sp3", 4, 3, 2, 1.500, 103.200, 200.100 ), ( 8, "HG2", "H", "", 7, 4, 3, 1.090, 109.500, 218.000 ), ( 9, "HG3", "H", "", 7, 4, 3, 1.090, 109.500, 98.000 ), ( 10, "CB ", "C", "sp3", 7, 4, 3, 1.510, 106.000, 338.300 ), ( 11, "HB2", "H", "", 10, 7, 4, 1.090, 109.500, 256.300 ), ( 12, "HB3", "H", "", 10, 7, 4, 1.090, 109.500, 136.300 ), ( 13, "CA ", "C", "sp3", 3, 2, 1, 1.451, 120.600, 175.200 ), ( 14, "HA ", "H", "", 13, 3, 2, 1.090, 109.500, 60.000 ), ( 15, "C ", "C", "sp2", 13, 3, 2, 1.522, 109.500, 300.000 ), ( 16, "O ", "O", "sp2", 15, 13, 3, 1.229, 120.500, 0.000 ), ] CYS_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "SG ", "S", "sp3", 7, 5, 3, 1.810, 116.000, 180.000 ), ( 11, "HG ", "H", "", 10, 7, 5, 1.330, 96.000, 180.000 ), ( 12, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 13, "O ", "O", "sp2", 12, 5, 3, 1.229, 120.500, 0.000 ), ] MET_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 11, "HG2", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "HG3", "H", "", 10, 7, 5, 1.090, 109.500, 60.000 ), ( 13, "SD ", "S", "sp3", 10, 7, 5, 1.810, 110.000, 180.000 ), ( 14, "CE ", "C", "sp3", 13, 10, 7, 1.780, 100.000, 180.000 ), ( 15, "HE1", "H", "", 14, 13, 10, 1.090, 109.500, 60.000 ), ( 16, "HE2", "H", "", 14, 13, 10, 1.090, 109.500, 180.000 ), ( 17, "HE3", "H", "", 14, 13, 10, 1.090, 109.500, 300.000 ), ( 18, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 19, "O ", "O", "sp2", 18, 5, 3, 1.229, 120.500, 0.000 ), ] THR_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB ", "H", "", 7, 5, 3, 1.090, 109.500, 180.000 ), ( 9, "CG2", "C", "sp3", 7, 5, 3, 1.525, 109.470, 300.000 ), ( 10, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 60.000 ), ( 11, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 180.000 ), ( 12, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 300.000 ), ( 13, "OG1", "O", "sp3", 7, 5, 3, 1.430, 109.470, 60.000 ), ( 14, "HG1", "H", "", 13, 7, 5, 0.960, 109.470, 180.000 ), ( 15, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 16, "O ", "O", "sp2", 15, 5, 3, 1.229, 120.500, 0.000 ), ] LEU_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 11, "HG ", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "CD1", "C", "sp3", 10, 7, 5, 1.525, 109.470, 60.000 ), ( 13, "HD1", "H", "", 12, 10, 7, 1.090, 109.500, 60.000 ), ( 14, "HD1", "H", "", 12, 10, 7, 1.090, 109.500, 180.000 ), ( 15, "HD1", "H", "", 12, 10, 7, 1.090, 109.500, 300.000 ), ( 16, "CD2", "C", "sp3", 10, 7, 5, 1.525, 109.470, 180.000 ), ( 17, "HD2", "H", "", 16, 10, 7, 1.090, 109.500, 60.000 ), ( 18, "HD2", "H", "", 16, 10, 7, 1.090, 109.500, 180.000 ), ( 19, "HD2", "H", "", 16, 10, 7, 1.090, 109.500, 300.000 ), ( 20, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 21, "O ", "O", "sp2", 20, 5, 3, 1.229, 120.500, 0.000 ), ] ILE_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 109.470, 60.000 ), ( 8, "HB ", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "CG2", "C", "sp3", 7, 5, 3, 1.525, 109.470, 60.000 ), ( 10, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 60.000 ), ( 11, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 180.000 ), ( 12, "HG2", "H", "", 9, 7, 5, 1.090, 109.500, 300.000 ), ( 13, "CG1", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 14, "HG1", "H", "", 13, 7, 5, 1.090, 109.500, 300.000 ), ( 15, "HG1", "H", "", 13, 7, 5, 1.090, 109.500, 60.000 ), ( 16, "CD1", "C", "sp3", 13, 7, 5, 1.525, 109.470, 180.000 ), ( 17, "HD1", "H", "", 16, 13, 7, 1.090, 109.500, 60.000 ), ( 18, "HD1", "H", "", 16, 13, 7, 1.090, 109.500, 180.000 ), ( 19, "HD1", "H", "", 16, 13, 7, 1.090, 109.500, 300.000 ), ( 20, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 21, "O ", "O", "sp2", 20, 5, 3, 1.229, 120.500, 0.000 ), ] VAL_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB ", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "CG1", "C", "sp3", 7, 5, 3, 1.525, 109.470, 60.000 ), ( 10, "HG1", "H", "", 9, 7, 5, 1.090, 109.500, 60.000 ), ( 11, "HG1", "H", "", 9, 7, 5, 1.090, 109.500, 180.000 ), ( 12, "HG1", "H", "", 9, 7, 5, 1.090, 109.500, 300.000 ), ( 13, "CG2", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 14, "HG2", "H", "", 13, 7, 5, 1.090, 109.500, 60.000 ), ( 15, "HG2", "H", "", 13, 7, 5, 1.090, 109.500, 180.000 ), ( 16, "HG2", "H", "", 13, 7, 5, 1.090, 109.500, 300.000 ), ( 17, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 18, "O ", "O", "sp2", 17, 5, 3, 1.229, 120.500, 0.000 ), ] TRP_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2", 7, 5, 3, 1.510, 115.000, 180.000 ), ( 11, "CD1", "C", "sp2", 10, 7, 5, 1.340, 127.000, 180.000 ), ( 12, "HD1", "H", "", 11, 10, 7, 1.090, 120.000, 0.000 ), ( 13, "NE1", "N", "sp3", 11, 10, 7, 1.430, 107.000, 180.000 ), ( 14, "HE1", "H", "", 13, 11, 10, 1.010, 125.500, 180.000 ), ( 15, "CE2", "C", "sp2a", 13, 11, 10, 1.310, 109.000, 0.000 ), ( 16, "CZ2", "C", "sp2a", 15, 13, 11, 1.400, 128.000, 180.000 ), ( 17, "HZ2", "H", "", 16, 15, 13, 1.090, 120.000, 0.000 ), ( 18, "CH2", "C", "sp2a", 16, 15, 13, 1.390, 116.000, 180.000 ), ( 19, "HH2", "H", "", 18, 16, 15, 1.090, 120.000, 180.000 ), ( 20, "CZ3", "C", "sp2a", 18, 16, 15, 1.350, 121.000, 0.000 ), ( 21, "HZ3", "H", "", 20, 18, 16, 1.090, 120.000, 180.000 ), ( 22, "CE3", "C", "sp2a", 20, 18, 16, 1.410, 122.000, 0.000 ), ( 23, "HE3", "H", "", 22, 20, 18, 1.090, 120.000, 180.000 ), ( 24, "CD2", "C", "sp2a", 22, 20, 18, 1.400, 117.000, 0.000 ), ( 25, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 26, "O ", "O", "sp2", 25, 5, 3, 1.229, 120.500, 0.000 ), ] TYR_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2a", 7, 5, 3, 1.510, 109.470, 180.000 ), ( 11, "CD1", "C", "sp2a", 10, 7, 5, 1.400, 120.000, 180.000 ), ( 12, "HD1", "H", "", 11, 10, 7, 1.090, 120.000, 0.000 ), ( 13, "CE1", "C", "sp2a", 11, 10, 7, 1.400, 120.000, 180.000 ), ( 14, "HE1", "H", "", 13, 11, 10, 1.090, 120.000, 180.000 ), ( 15, "CZ ", "C", "sp2a", 13, 11, 10, 1.400, 120.000, 0.000 ), ( 16, "OH ", "O", "sp3", 15, 13, 11, 1.360, 120.000, 180.000 ), ( 17, "HH ", "H", "", 16, 15, 13, 0.960, 113.000, 0.000 ), ( 18, "CE2", "C", "sp2a", 15, 13, 11, 1.400, 120.000, 0.000 ), ( 19, "HE2", "H", "", 18, 15, 13, 1.090, 120.000, 180.000 ), ( 20, "CD2", "C", "sp2a", 18, 15, 13, 1.400, 120.000, 0.000 ), ( 21, "HD2", "H", "", 20, 18, 15, 1.090, 120.000, 180.000 ), ( 22, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 23, "O ", "O", "sp2", 22, 5, 3, 1.229, 120.500, 0.000 ), ] LYS_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 11, "HG2", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "HG3", "H", "", 10, 7, 5, 1.090, 109.500, 60.000 ), ( 13, "CD ", "C", "sp3", 10, 7, 5, 1.525, 109.470, 180.000 ), ( 14, "HD2", "H", "", 13, 10, 7, 1.090, 109.500, 300.000 ), ( 15, "HD3", "H", "", 13, 10, 7, 1.090, 109.500, 60.000 ), ( 16, "CE ", "C", "sp3", 13, 10, 7, 1.525, 109.470, 180.000 ), ( 17, "HE2", "H", "", 16, 13, 10, 1.090, 109.500, 300.000 ), ( 18, "HE3", "H", "", 16, 13, 10, 1.090, 109.500, 60.000 ), ( 19, "NZ ", "N", "sp3", 16, 13, 10, 1.470, 109.470, 180.000 ), ( 20, "HZ1", "H", "", 19, 16, 13, 1.010, 109.470, 60.000 ), ( 21, "HZ2", "H", "", 19, 16, 13, 1.010, 109.470, 180.000 ), ( 22, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 23, "O ", "O", "sp2", 22, 5, 3, 1.229, 120.500, 0.000 ), ] ARG_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 11, "HG2", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "HG3", "H", "", 10, 7, 5, 1.090, 109.500, 60.000 ), ( 13, "CD ", "C", "sp3", 10, 7, 5, 1.525, 109.470, 180.000 ), ( 14, "HD2", "H", "", 13, 10, 7, 1.090, 109.500, 300.000 ), ( 15, "HD3", "H", "", 13, 10, 7, 1.090, 109.500, 60.000 ), ( 16, "NE ", "N", "sp3", 13, 10, 7, 1.480, 111.000, 180.000 ), ( 17, "HE ", "H", "", 16, 13, 10, 1.010, 118.500, 0.000 ), ( 18, "CZ ", "C", "sp2", 16, 13, 10, 1.330, 123.000, 180.000 ), ( 19, "NH1", "N", "sp3", 18, 16, 13, 1.330, 122.000, 0.000 ), ( 20, "HH1", "H", "", 19, 18, 16, 1.010, 119.800, 0.000 ), ( 21, "HH1", "H", "", 19, 18, 16, 1.010, 119.800, 180.000 ), ( 22, "NH2", "N", "sp2", 18, 16, 13, 1.330, 118.000, 180.000 ), ( 23, "HH2", "H", "", 22, 18, 16, 1.010, 119.800, 0.000 ), ( 24, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 25, "O ", "O", "sp2", 24, 5, 3, 1.229, 120.500, 0.000 ), ] HIS_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2", 7, 5, 3, 1.510, 115.000, 180.000 ), ( 11, "ND1", "N", "sp3", 10, 7, 5, 1.390, 122.000, 180.000 ), ( 12, "HD1", "H", "", 11, 10, 7, 1.010, 126.000, 0.000 ), ( 13, "CE1", "C", "sp2", 11, 10, 7, 1.320, 108.000, 180.000 ), ( 14, "HE1", "H", "", 13, 11, 10, 1.090, 120.000, 180.000 ), ( 15, "NE2", "N", "sp2s", 13, 11, 10, 1.310, 109.000, 0.000 ), ( 16, "CD2", "C", "sp2s", 15, 13, 11, 1.360, 110.000, 0.000 ), ( 17, "HD2", "H", "", 16, 15, 13, 1.090, 120.000, 180.000 ), ( 18, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 19, "O ", "O", "sp2", 18, 5, 3, 1.229, 120.500, 0.000 ), ] ASP_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2", 7, 5, 3, 1.527, 109.470, 180.000 ), ( 11, "OD1", "O", "sp2", 10, 7, 5, 1.260, 117.200, 90.000 ), ( 12, "OD2", "O", "sp3", 10, 7, 5, 1.260, 117.200, 270.000 ), ( 13, "HD2", "H", "", 12, 10, 7, 0.960, 109.500, 180.000 ), ( 14, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 15, "O ", "O", "sp2", 14, 5, 3, 1.229, 120.500, 0.000 ), ] ASN_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp2", 7, 5, 3, 1.522, 111.100, 180.000 ), ( 11, "OD1", "O", "sp2", 10, 7, 5, 1.229, 120.500, 0.000 ), ( 12, "ND2", "N", "sp3", 10, 7, 5, 1.335, 116.600, 180.000 ), ( 13, "HD2", "H", "", 12, 10, 7, 1.010, 119.800, 180.000 ), ( 14, "HD2", "H", "", 12, 10, 7, 1.010, 119.800, 0.000 ), ( 15, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 16, "O ", "O", "sp2", 15, 5, 3, 1.229, 120.500, 0.000 ), ] GLN_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "N", "sp2(graphitic)", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 1.010, 119.800, 0.000 ), ( 5, "CA ", "C", "sp3", 3, 2, 1, 1.449, 121.900, 180.000 ), ( 6, "HA ", "H", "", 5, 3, 2, 1.090, 109.500, 300.000 ), ( 7, "CB ", "C", "sp3", 5, 3, 2, 1.525, 111.100, 60.000 ), ( 8, "HB2", "H", "", 7, 5, 3, 1.090, 109.500, 300.000 ), ( 9, "HB3", "H", "", 7, 5, 3, 1.090, 109.500, 60.000 ), ( 10, "CG ", "C", "sp3", 7, 5, 3, 1.525, 109.470, 180.000 ), ( 11, "HG2", "H", "", 10, 7, 5, 1.090, 109.500, 300.000 ), ( 12, "HG3", "H", "", 10, 7, 5, 1.090, 109.500, 60.000 ), ( 13, "CD ", "C", "sp2", 10, 7, 5, 1.522, 111.100, 180.000 ), ( 14, "OE1", "O", "sp2", 13, 10, 7, 1.229, 120.500, 0.000 ), ( 15, "NE2", "N", "sp3", 13, 10, 7, 1.335, 116.600, 180.000 ), ( 16, "HE2", "H", "", 15, 13, 10, 1.010, 119.800, 180.000 ), ( 17, "HE2", "H", "", 15, 13, 10, 1.010, 119.800, 0.000 ), ( 18, "C ", "C", "sp2", 5, 3, 2, 1.522, 111.100, 180.000 ), ( 19, "O ", "O", "sp2", 18, 5, 3, 1.229, 120.500, 0.000 ), ] NTERM_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "H", "", 2, 1, 0, 1.335, 116.600, 180.000 ), ] # Note: this is just a fake "N " label for the _buildResiduum # to make it thinking that we are starting a new amino acid. CTERM_ZMATRIX = [ ( 0, "DUM", "", "", -1, -2, -3, 0.000, 0.000, 0.000 ), ( 1, "DUM", "", "", 0, -1, -2, 1.449, 0.000, 0.000 ), ( 2, "DUM", "", "", 1, 0, -1, 1.522, 111.100, 0.000 ), ( 3, "N ", "O", "sp3", 2, 1, 0, 1.335, 116.600, 180.000 ), ( 4, "H ", "H", "", 3, 2, 1, 0.960, 109.500, 0.000 ), ] # all amino acids, z-matrices and their sizes AMINO_ACIDS = [ ( "Alanine", "ALA", "A", ALA_ZMATRIX, 13 ), ( "Arginine", "ARG", "R", ARG_ZMATRIX, 26 ), ( "Asparagine", "ARG", "N", ASN_ZMATRIX, 17 ), ( "Aspartic Acid", "ARG", "D", ASP_ZMATRIX, 16 ), ( "Cysteine", "CYS", "C", CYS_ZMATRIX, 14 ), ( "Glutamic Acid", "GLU", "E", GLU_ZMATRIX, 19 ), ( "Glutamine", "GLN", "Q", GLN_ZMATRIX, 20 ), ( "Glycine", "GLY", "G", GLY_ZMATRIX, 10 ), ( "Histidine", "HIS", "H", HIS_ZMATRIX, 20 ), ( "Isoleucine", "ILE", "I", ILE_ZMATRIX, 22 ), ( "Leucine", "LEU", "L", LEU_ZMATRIX, 22 ), ( "Lysine", "LYS", "K", LYS_ZMATRIX, 24 ), ( "Methionine", "MET", "M", MET_ZMATRIX, 20 ), ( "Phenylalanine", "PHE", "F", PHE_ZMATRIX, 23 ), ( "Proline", "PRO", "P", PRO_ZMATRIX, 17 ), ( "Serine", "SER", "S", SER_ZMATRIX, 14 ), ( "Threonine", "THR", "T", THR_ZMATRIX, 17 ), ( "Tryptophan", "TRP", "W", TRP_ZMATRIX, 27 ), ( "Tyrosine", "TYR", "Y", TYR_ZMATRIX, 24 ), ( "Valine", "VAL", "V", VAL_ZMATRIX, 19 ) ] # degrees to radians conversion DEG2RAD = (pi/180.0) def enablePeptideGenerator(enable): """ This function enables/disables the Peptide Generator command by hiding or showing it in the Command Manager toolbar and menu. The enabling/disabling is done by the user via the "secret" NE1 debugging menu. To display the secret debugging menu, hold down Shift+Ctrl+Alt keys (or Shift+Cmd+Alt on Mac) and right click over the graphics area. Select "debug prefs submenu > Peptide Generator" and set the value to True. The "Peptide" option will then appear on the "Build" Command Manager toolbar/menu. @param enable: If true, the Peptide Generator is enabled. Specifically, it will be added to the "Build" Command Manager toolbar and menu. @type enable: bool """ win = env.mainwindow() win.insertPeptideAction.setVisible(enable) class PeptideGenerator(PeptideGeneratorPropertyManager, GeneratorBaseClass): """ The Peptide Generator class for the "Build > Peptide" command. """ cmd = greenmsg("Build Peptide: ") prefix = 'Peptide' # used for gensym # Generators for DNA, peptides, nanotubes and graphene have their MT name generated # (in GeneratorBaseClass) from the prefix. create_name_from_prefix = True # Peptide sponsor keywords sponsor_keyword = ('Peptides', 'Proteins') def __init__(self, win): self.coords = zeros([30,3], Float) self.prev_coords = zeros([3,3], Float) self.peptide_mol = None self.length = 0 self.prev_psi = 0 PeptideGeneratorPropertyManager.__init__(self) GeneratorBaseClass.__init__(self, win) def gather_parameters(self): """ Return all the parameters from the Property Manager dialog. """ return (self.length) def _buildResiduum(self, mol, zmatrix, n_atoms, phi, psi, init_pos, symbol): """ Builds cartesian coordinates for an amino acid from the internal coordinates table. mol is a chunk to which the amino acid will be added. zmatrix is an internal coordinates array corresponding to a given amino acid. n_atoms is a number of atoms to be build + 3 dummy atoms. phi is a peptide bond PHI angle. psi is a peptide bond PSI angle. init_pos are optional postions of previous CA, C and O atoms. symbol is a current amino acid symbol (used for proline case) Note: currently, it doesn't rebuild bonds, so inferBonds has to be called after. Unfortunately, the proper bond order can not be correctly recognized this way. """ if mol == None: return if not init_pos: # assign three previous atom positions for i in range (0,3): self.coords[i][0] = self.prev_coords[i][0] self.coords[i][1] = self.prev_coords[i][1] self.coords[i][2] = self.prev_coords[i][2] else: # if no prev_coords are given, compute the first three atom positions num, name, atom_name, atom_type, \ atom_c, atom_b, atom_a, r, a, t = zmatrix[1] self.coords[0][0] = 0.0; self.coords[0][1] = 0.0; self.coords[0][2] = 0.0; self.coords[1][0] = r; self.coords[1][1] = 0.0; self.coords[1][2] = 0.0; ccos = cos(DEG2RAD*a) num, name, atom_name, atom_type, \ atom_c, atom_b, atom_a, r, a, t = zmatrix[2] if atom_c == 1: self.coords[2][0] = self.coords[0][0] + r*ccos else: self.coords[2][0] = self.coords[0][0] - r*ccos self.coords[2][1] = r * sin(DEG2RAD*a) self.coords[2][2] = 0.0 for i in range (0, 3): self.prev_coords[i][0] = self.coords[i][0] + init_pos[0] self.prev_coords[i][1] = self.coords[i][1] + init_pos[1] self.prev_coords[i][2] = self.coords[i][2] + init_pos[2] for n in range (3, n_atoms): # Generate all coordinates using three previous atoms # as a frame of reference, num, name, atom_name, atom_type, \ atom_c, atom_b, atom_a, r, a, t = zmatrix[n] cosa = cos(DEG2RAD * a) xb = self.coords[atom_b][0] - self.coords[atom_c][0] yb = self.coords[atom_b][1] - self.coords[atom_c][1] zb = self.coords[atom_b][2] - self.coords[atom_c][2] rbc = 1.0 / sqrt(xb*xb + yb*yb + zb*zb) if abs(cosa) >= 0.999: # Linear bond case # Skip angles, just extend along the bond. rbc = r * rbc * cosa self.coords[n][0] = self.coords[atom_c][0] + xb*rbc self.coords[n][1] = self.coords[atom_c][1] + yb*rbc self.coords[n][2] = self.coords[atom_c][2] + zb*rbc else: xa = self.coords[atom_a][0] - self.coords[atom_c][0] ya = self.coords[atom_a][1] - self.coords[atom_c][1] za = self.coords[atom_a][2] - self.coords[atom_c][2] xyb = sqrt(xb*xb + yb*yb) inv = False if xyb < 0.001: xpa = za za = -xa xa = xpa xpb = zb zb = -xb xb = xpb xyb = sqrt(xb*xb + yb*yb) inv = True costh = xb / xyb sinth = yb / xyb xpa = xa * costh + ya * sinth ypa = ya * costh - xa * sinth sinph = zb * rbc cosph = sqrt(abs(1.0- sinph * sinph)) xqa = xpa * cosph + za * sinph zqa = za * cosph - xpa * sinph yza = sqrt(ypa * ypa + zqa * zqa) if yza < 1e-8: coskh = 1.0 sinkh = 0.0 else: coskh = ypa / yza sinkh = zqa / yza # Apply the peptide bond conformation if symbol != "P": if name == "N " and not init_pos: t = self.prev_psi + 0.0 if name == "O ": t = psi + 180.0 if name == "HA " or name == "HA2": t = 120.0 + phi if name == "CB " or name == "HA3": t = 240.0 + phi if name == "C ": t = phi else: # proline if name == "N " and not init_pos: t = self.prev_psi + 0.0 if name == "O ": t = psi + 180.0 if name == "CA ": t = phi - 120.0 if name == "CD ": t = phi + 60.0 sina = sin(DEG2RAD * a) sind = -sin(DEG2RAD * t) cosd = cos(DEG2RAD * t) # Apply the bond length. xd = r * cosa yd = r * sina * cosd zd = r * sina * sind # Compute the atom position using bond and torsional angles. ypd = yd * coskh - zd * sinkh zpd = zd * coskh + yd * sinkh xpd = xd * cosph - zpd * sinph zqd = zpd * cosph + xd * sinph xqd = xpd * costh - ypd * sinth yqd = ypd * costh + xpd * sinth if inv: tmp = -zqd zqd = xqd xqd = tmp self.coords[n][0] = xqd + self.coords[atom_c][0] self.coords[n][1] = yqd + self.coords[atom_c][1] self.coords[n][2] = zqd + self.coords[atom_c][2] if self.nterm_hydrogen: # It is a hack for the first hydrogen atom # to make sure the bond length is correct. self.nterm_hydrogen.setposn( self.nterm_hydrogen.posn() + 0.325 * norm(V(xqd, yqd, zqd))) self.nterm_hydrogen = None ax = self.coords[n][0] ay = self.coords[n][1] az = self.coords[n][2] # Store previous coordinates for the next building step if not init_pos: if name=="N ": self.prev_coords[0][0] = self.coords[n][0] self.prev_coords[0][1] = self.coords[n][1] self.prev_coords[0][2] = self.coords[n][2] if name=="CA ": self.prev_coords[1][0] = self.coords[n][0] self.prev_coords[1][1] = self.coords[n][1] self.prev_coords[1][2] = self.coords[n][2] if name=="C ": self.prev_coords[2][0] = self.coords[n][0] self.prev_coords[2][1] = self.coords[n][1] self.prev_coords[2][2] = self.coords[n][2] # Add a new atom to the molecule atom = Atom( atom_name, V(self.coords[n][0], self.coords[n][1], self.coords[n][2]), mol) # Create temporary attributes for proper bond assignment. atom._is_aromatic = False atom._is_single = False if atom_type == "sp2a": atom_type = "sp2" atom._is_aromatic = True if atom_type == "sp2s": atom_type = "sp2" atom._is_single = True atom.set_atomtype_but_dont_revise_singlets(atom_type) if name == "CA ": # Set c-alpha flag for protein main chain visualization. atom._protein_ca = True else: atom._protein_ca = False if name == "CB ": # Set c-alpha flag for protein main chain visualization. atom._protein_cb = True else: atom._protein_cb = False if name == "N ": # Set c-alpha flag for protein main chain visualization. atom._protein_n = True else: atom._protein_n = False if name == "C ": # Set c-alpha flag for protein main chain visualization. atom._protein_c = True else: atom._protein_c = False if name == "O ": # Set c-alpha flag for protein main chain visualization. atom._protein_o = True else: atom._protein_o = False # debug - output in PDB format # print "ATOM %5d %-3s %3s %c%4d %8.3f%8.3f%8.3f" % ( n, name, "ALA", ' ', res_num, coords[n][0], coords[n][1], coords[n][2]) self.prev_psi = psi # Remember previous psi angle. self.length += 1 # Increase the amino acid counter. return def build_struct(self, name, params, position, mol=None, createPrinted=False): """ Build a peptide from a sequence entered through the Property Manager dialog. """ if len(self.peptide_cache) == 0: return None # Create a molecule mol = Chunk(self.win.assy,name) # Generate dummy atoms positions self.prev_coords[0][0] = position[0] - 1.499 self.prev_coords[0][1] = position[1] + 1.539 self.prev_coords[0][2] = position[2] self.prev_coords[1][0] = position[0] - 1.499 self.prev_coords[1][1] = position[1] self.prev_coords[1][2] = position[2] self.prev_coords[2][0] = position[0] self.prev_coords[2][1] = position[1] self.prev_coords[2][2] = position[2] # Add a N-terminal hydrogen atom = Atom("H", position, mol) atom._is_aromatic = False atom._is_single = False self.nterm_hydrogen = atom # Generate the peptide chain. self.length = 1 for index, phi, psi in self.peptide_cache: name, short_name, symbol, zmatrix, size = AMINO_ACIDS[index] self._buildResiduum(mol, zmatrix, size, phi, psi, None, symbol) # Add a C-terminal OH group self._buildResiduum(mol, CTERM_ZMATRIX, 5, 0.0, 0.0, None, symbol) # Compute bonds (slow!) # This should be replaced by a proper bond assignment. inferBonds(mol) mol._protein_helix = [] mol._protein_sheet = [] # Assign proper bond orders. i = 1 for atom in mol.atoms.itervalues(): if self.ss_idx == 1: mol._protein_helix.append(i) elif self.ss_idx == 2: mol._protein_sheet.append(i) if atom.bonds: for bond in atom.bonds: if bond.atom1.getAtomTypeName()=="sp2" and \ bond.atom2.getAtomTypeName()=="sp2": if (bond.atom1._is_aromatic and bond.atom2._is_aromatic): bond.set_v6(V_AROMATIC) elif ((bond.atom1._is_aromatic == False and bond.atom1._is_aromatic == False) and not (bond.atom1._is_single and bond.atom2._is_single)): bond.set_v6(V_DOUBLE) i += 1 # Remove temporary attributes. for atom in mol.atoms.itervalues(): del atom._is_aromatic del atom._is_single return mol def addAminoAcid(self, index): """ Adds a new amino acid to the peptide molecule. This is going to be displayed after user accepts or previews the structure. """ # add a new amino acid and chain conformation to the peptide cache self.peptide_cache.append((index,self.phi,self.psi)) return # end