Пример #1
0
 def strandinfo(self):
     for i in range(len(self.strands) - 1, -1, -1):
         print self.startpos[i] + len(self.strands[i]) - 1
         for j in range(len(self.strands[i]) - 1, -1, -1):
             print str(self.strands[i][j][Ball.p_resseqid]).zfill(3) + aminoacid.getaacode(
                 self.strands[i][j][Ball.p_aaid]
             )
         print "~~~~~~~~~~~~~"
Пример #2
0
Файл: utils.py Проект: jksr/bbtm
def writepdb(pdbfn, barrel, structname = '', pdb = False, sticks = False, supp = False):
	balls = barrel.balls
	if pdb:
		supp = False
		balls = barrel.pdbballs

	chain = Bio.PDB.Chain.Chain("A")
	for i in range(barrel.aanum):
		res_id = (' ', balls[i][Ball.p_resseqid], ' ')
		res_type = aminoacid.getaacode(balls[i][Ball.p_aaid])
		res = Bio.PDB.Residue.Residue(res_id, res_type, ' ')
		coord = (balls[i][Ball.p_coordx], balls[i][Ball.p_coordy], balls[i][Ball.p_coordz])
		atom = Bio.PDB.Atom.Atom('CA', coord, 0, 0, ' ', 'CA', balls[i][Ball.p_resseqid], 'C')
		res.add(atom)
		chain.add(res)

	if supp:
		for i in range(barrel.aanum, len(balls)):
			res_id = (' ', balls[i][Ball.p_resseqid], ' ')
			res_type = 'X'
			res = Bio.PDB.Residue.Residue(res_id, res_type, ' ')
			coord = (balls[i][Ball.p_coordx], balls[i][Ball.p_coordy], balls[i][Ball.p_coordz])
			atom = Bio.PDB.Atom.Atom('CA', coord, 0, 0, ' ', 'CA', balls[i][Ball.p_resseqid], 'C')
			res.add(atom)
			chain.add(res)
	
	model = Bio.PDB.Model.Model(1)
	model.add(chain)
	structure = Bio.PDB.Structure.Structure(structname)
	structure.add(model)
	io = Bio.PDB.PDBIO()
	io.set_structure(structure)
	io.save(pdbfn, write_end=False)

	with open(pdbfn, 'a') as fout:
		if sticks:
			if supp:
				stknum = len(barrel.sticks)
			else:
				stknum = barrel.bondnum
			for i in range(stknum):
				id1 = barrel.sticks[i][Stick.p_ball1id]
				id2 = barrel.sticks[i][Stick.p_ball2id]
				#fout.write( 'CONECT%5d%5d\n' % (barrel.balls[id1][Ball.p_resseqid], barrel.balls[id2][Ball.p_resseqid]) )
				fout.write( 'CONECT%5d%5d\n' % (id1+1, id2+1) )
		fout.write('END\n')