Example #1
0
	def validGeometry_DHAB(self, tags1, tags2, reslines1, reslines2) : ## implement in subclasses
		## D and H coordinates from reslines1
		Dcrd, Hcrds = self.DHcrd(reslines1, tags1)
		## A and B coordinates from reslines2
		Acrd, Bcrd, Aatomname, Batomname = None, None, None, None
		for tat in tags2 :
			if tat.tag == 'A' : Aatomname = tat.atn
			if tat.tag == 'B' : Batomname = tat.atn
		for rl in reslines2 :
			if Aatomname == line2atomname(rl) : Acrd = line2crd(rl)
			if Batomname == line2atomname(rl) : Bcrd = line2crd(rl)
		## limit checks
		tag2points = {}
		tag2points['D'] = Dcrd
		tag2points['A'] = Acrd
		tag2points['B'] = Bcrd
		if len(Hcrds) == 0 : Hcrds = [(1e6,1e6,1e6)] ## probably hydrogens have no role in this intxn, thats why they were not discovered
		for hcrd in Hcrds :
			tag2points['H'] = hcrd
			all_lims_satisfied = 1
			for l in self.lims :
				#print tag2points
				if not l.check(tag2points) :
					all_lims_satisfied = 0
					break
			if all_lims_satisfied == 1 : return pymol_line(Dcrd, Acrd)
		return None
Example #2
0
 def validGeometry_contact(self, tags1, tags2, reslines1, reslines2,
                           atomnbrs):  ## implement in subclasses
     contact = None
     for an1 in tags1:
         if contact: break
         for an2 in tags2:
             if contact: break
             if (an1.atn, an2.atn) in atomnbrs: contact = 1
     if not contact: return None
     c1, c2, H1crd, H2crd = 0, 0, [
         0.,
         0.,
         0.,
     ], [
         0.,
         0.,
         0.,
     ]
     for rl in reslines1:
         for an in tags1:
             if line2atomname(rl) == an.atn:
                 H1crd = vec_add(H1crd, line2crd(rl))
                 c1 = c1 + 1
     for rl in reslines2:
         for an in tags2:
             if line2atomname(rl) == an.atn:
                 H2crd = vec_add(H2crd, line2crd(rl))
                 c2 = c2 + 1
     H1crd = vec_scale(H1crd, 1. / c1)
     H2crd = vec_scale(H2crd, 1. / c2)
     return pymol_line(H1crd, H2crd)
Example #3
0
 def validGeometry_DHAB(self, tags1, tags2, reslines1,
                        reslines2):  ## implement in subclasses
     ## D and H coordinates from reslines1
     Dcrd, Hcrds = self.DHcrd(reslines1, tags1)
     ## A and B coordinates from reslines2
     Acrd, Bcrd, Aatomname, Batomname = None, None, None, None
     for tat in tags2:
         if tat.tag == 'A': Aatomname = tat.atn
         if tat.tag == 'B': Batomname = tat.atn
     for rl in reslines2:
         if Aatomname == line2atomname(rl): Acrd = line2crd(rl)
         if Batomname == line2atomname(rl): Bcrd = line2crd(rl)
     ## limit checks
     tag2points = {}
     tag2points['D'] = Dcrd
     tag2points['A'] = Acrd
     tag2points['B'] = Bcrd
     if len(Hcrds) == 0:
         Hcrds = [
             (1e6, 1e6, 1e6)
         ]  ## probably hydrogens have no role in this intxn, thats why they were not discovered
     for hcrd in Hcrds:
         tag2points['H'] = hcrd
         all_lims_satisfied = 1
         for l in self.lims:
             #print tag2points
             if not l.check(tag2points):
                 all_lims_satisfied = 0
                 break
         if all_lims_satisfied == 1: return pymol_line(Dcrd, Acrd)
     return None
Example #4
0
	def DHcrd(self, reslines, tags) :
		Datomname = None
		for tat in tags :
			if tat.tag == 'D' : Datomname = tat.atn
		Hatomname = '.H' + Datomname[2:4]
		Dcrd, Hcrds = None, []
		for rl in reslines :
			if re.compile(Hatomname).search(line2atomname(rl)) : Hcrds.append(line2crd(rl))
			if Datomname == line2atomname(rl) : Dcrd = line2crd(rl)
		return Dcrd, Hcrds
Example #5
0
 def DHcrd(self, reslines, tags):
     Datomname = None
     for tat in tags:
         if tat.tag == 'D': Datomname = tat.atn
     Hatomname = '.H' + Datomname[2:4]
     Dcrd, Hcrds = None, []
     for rl in reslines:
         if re.compile(Hatomname).search(line2atomname(rl)):
             Hcrds.append(line2crd(rl))
         if Datomname == line2atomname(rl): Dcrd = line2crd(rl)
     return Dcrd, Hcrds
Example #6
0
	def validGeometry_contact(self, tags1, tags2, reslines1, reslines2, atomnbrs) : ## implement in subclasses
		contact = None
		for an1 in tags1 :
			if contact : break
			for an2 in tags2 :
				if contact : break
				if (an1.atn,an2.atn) in atomnbrs : contact = 1
		if not contact : return None
		c1,c2, H1crd, H2crd = 0,0, [0.,0.,0.,], [0.,0.,0.,]
		for rl in reslines1 :
			for an in tags1 :
				if line2atomname(rl) == an.atn : 
					H1crd = vec_add(H1crd, line2crd(rl))
					c1 = c1 + 1
		for rl in reslines2 :
			for an in tags2 :
				if line2atomname(rl) == an.atn : 
					H2crd = vec_add(H2crd, line2crd(rl))
					c2 = c2 + 1
		H1crd = vec_scale(H1crd, 1./c1)
		H2crd = vec_scale(H2crd, 1./c2)
		return pymol_line(H1crd, H2crd)
Example #7
0
	def Rcrd(self, reslines, tags) :
		Ratomnames = []
		for tat in tags :
			if tat.tag == 'R' : Ratomnames.append(tat.atn)
		Rcrd, AMcrd, ANcrd = [], [0.,0.,0.], []
		for rl in reslines :
			if line2atomname(rl) in Ratomnames : Rcrd.append(line2crd(rl))
		assert len(Rcrd) >= 3
		for rc in Rcrd : AMcrd = vec_add(AMcrd, rc)
		AMcrd = vec_scale(AMcrd, 1./len(Rcrd))
		AN = cross_product(vec_diff(Rcrd[0], Rcrd[1]), vec_diff(Rcrd[2], Rcrd[1]))
		ANcrd.append(vec_add(AMcrd, AN))
		ANcrd.append(vec_diff(AMcrd, AN))
		return AMcrd, ANcrd
Example #8
0
def readProtRes(prot) :
    res, resids, resnums, resnames, chids, resics, crds = {}, {}, {}, {}, {}, {}, []
    for ri in range(len(prot.reslines)) :
        start, stop = prot.reslines[ri]
        resids[ri] = line2resid( prot.atomlines[start] )
        resnames[ri] = line2resn( prot.atomlines[start] )
        resnums[ri] = line2resnum( prot.atomlines[start] )
        chids[ri] = line2chid( prot.atomlines[start] )
        resics[ri] = line2resic( prot.atomlines[start] )
        res[ri] = {}
        for ai in range(start, stop) :
            crd = line2crd( prot.atomlines[ai] )
            aname = line2atomname( prot.atomlines[ai] )
            crds.append(crd)
            res[ri][aname] = len(crds)-1
    return res, resids, resnums, resnames, chids, resics, crds
Example #9
0
 def Rcrd(self, reslines, tags):
     Ratomnames = []
     for tat in tags:
         if tat.tag == 'R': Ratomnames.append(tat.atn)
     Rcrd, AMcrd, ANcrd = [], [0., 0., 0.], []
     for rl in reslines:
         if line2atomname(rl) in Ratomnames: Rcrd.append(line2crd(rl))
     assert len(Rcrd) >= 3
     for rc in Rcrd:
         AMcrd = vec_add(AMcrd, rc)
     AMcrd = vec_scale(AMcrd, 1. / len(Rcrd))
     AN = cross_product(vec_diff(Rcrd[0], Rcrd[1]),
                        vec_diff(Rcrd[2], Rcrd[1]))
     ANcrd.append(vec_add(AMcrd, AN))
     ANcrd.append(vec_diff(AMcrd, AN))
     return AMcrd, ANcrd
Example #10
0
def readProtRes3(prot) :
    res, resids, resnums, resnames, chids, resics, crds, hetids = {}, {}, {}, {}, {}, {}, [] , {}
    for ri in range(len(prot.reslines)) :
#        print prot.reslines[ri]
        start, stop = prot.reslines[ri]
#        print prot.atomlines[start]
        resids[ri] = line2resid( prot.atomlines[start] )
        resnames[ri] = line2resn( prot.atomlines[start] )
        resnums[ri] = line2resnum( prot.atomlines[start] )
        chids[ri] = line2chid( prot.atomlines[start] )
        resics[ri] = line2resic( prot.atomlines[start] )
        if isHetAtomLine( prot.atomlines[start] ) :
            hetids[ri] = 1
        else :

            hetids[ri] = 0
        res[ri] = {}

        for ai in range(start, stop) :
            crd = line2crd( prot.atomlines[ai] )
            aname = line2atomname( prot.atomlines[ai] )
            crds.append(crd)
            res[ri][aname] = len(crds)-1
    return res, resids, resnums, resnames, chids, resics, crds , hetids
Example #11
0
def readProtRes(prot) :
    res, resids, resnums, resnames, chids, resics, crds = {}, {}, {}, {}, {}, {}, []
    
    
    for ri in range(len(prot.reslines)) :
        start, stop = prot.reslines[ri]
        if start == 0 and  stop == 0:
            print "No ATOM records found in file"
            continue
        resids[ri] = line2resid( prot.atomlines[start] )
        resnames[ri] = line2resn( prot.atomlines[start] )
        resnums[ri] = line2resnum( prot.atomlines[start] )
        chids[ri] = line2chid( prot.atomlines[start] )
        resics[ri] = line2resic( prot.atomlines[start] )
        res[ri] = {}
        for ai in range(start, stop) :
            crd = line2crd( prot.atomlines[ai] )
            aname = line2atomname( prot.atomlines[ai] )
            crds.append(crd)
            res[ri][aname] = len(crds)-1
    if len(res.keys()) == 0  and start ==0 and stop ==0: 
        print "Coordinate file corrupted, pleas check file format. Unable to read coordinae file"
        import sys ; sys.exit()
    return res, resids, resnums, resnames, chids, resics, crds
Example #12
0
	parser.add_option("--intxml", action='store', type='string', dest="intxml", help='xml file describing interactions to be detected')
	parser.add_option("--out", action='store', type='string', dest="out", help='output xml file containing interactions, in a format readable with pymol plugin')
	parser.add_option("--reprez", action='store', type='string', dest="reprez", help='pdb file')

	(options, args) = parser.parse_args()

	intxml = options.intxml
	outfn = options.out

	## solvate protein and decide voronoi adjacency in un-reduced protein
	prot = protein(options.pdbin, read_hydrogens=0, read_waters=1, read_hets=1) ## pdb file here
	HOHcrd = makeGridZimmer(prot.allcrds())
	vor_in = []
	vor_in.append("3")
	vor_in.append("%d" % (len(prot.atomlines)+len(HOHcrd)))
	for l in prot.atomlines : vor_in.append("%f %f %f" % line2crd(l))
	for crd in HOHcrd : vor_in.append("%f %f %f" % crd)
	dontcare_estatus,vorface_lines,dontcare_elines = proc_run_exitOnError("qvoronoi Fv", vor_in) # voronoi vertices
	vornbrs = {}
	for i in range(len(prot.reslines)) :
		if not isPdbAAline(prot.atomlines[ prot.reslines[i][0] ]) : continue
		resid1 = line2resid( prot.atomlines[prot.reslines[i][0]] )
		for j in range(len(prot.reslines)) :
			if not isPdbAAline(prot.atomlines[ prot.reslines[j][0] ]) : continue
			resid2 = line2resid( prot.atomlines[prot.reslines[j][0]] )
			vornbrs[(resid1,resid2)] = []
	for l in vorface_lines[1:] : #ignore 1st line of output
		flds = l.split()[1:] #ignore first field of each line
		a0, a1 = string.atoi(flds[0]), string.atoi(flds[1])
		if a0 >= len(prot.atomlines) or a1 >= len(prot.atomlines) : continue
		if not isPdbAAline(prot.atomlines[a0]) or not isPdbAAline(prot.atomlines[a1]) : continue
Example #13
0
                      help='pdb file')

    (options, args) = parser.parse_args()

    intxml = options.intxml
    outfn = options.out

    ## solvate protein and decide voronoi adjacency in un-reduced protein
    prot = protein(options.pdbin, read_hydrogens=0, read_waters=1,
                   read_hets=1)  ## pdb file here
    HOHcrd = makeGridZimmer(prot.allcrds())
    vor_in = []
    vor_in.append("3")
    vor_in.append("%d" % (len(prot.atomlines) + len(HOHcrd)))
    for l in prot.atomlines:
        vor_in.append("%f %f %f" % line2crd(l))
    for crd in HOHcrd:
        vor_in.append("%f %f %f" % crd)
    dontcare_estatus, vorface_lines, dontcare_elines = proc_run_exitOnError(
        "qvoronoi Fv", vor_in)  # voronoi vertices
    vornbrs = {}
    for i in range(len(prot.reslines)):
        if not isPdbAAline(prot.atomlines[prot.reslines[i][0]]): continue
        resid1 = line2resid(prot.atomlines[prot.reslines[i][0]])
        for j in range(len(prot.reslines)):
            if not isPdbAAline(prot.atomlines[prot.reslines[j][0]]): continue
            resid2 = line2resid(prot.atomlines[prot.reslines[j][0]])
            vornbrs[(resid1, resid2)] = []
    for l in vorface_lines[1:]:  #ignore 1st line of output
        flds = l.split()[1:]  #ignore first field of each line
        a0, a1 = string.atoi(flds[0]), string.atoi(flds[1])