From: Andrea S. <and...@gm...> - 2005-07-05 10:50:31
|
Hi guys, I am trying to make a script to automatize a procedure. I have got a file where I can pick up the structure of protein-ligand complexes cluster The script below read the number of the cluster and then visualize them align with a protein reference. Everything is fine except I'd like write on a file the distances between some residues of each structure with the ligand but I cannot figure out how do it. I read different post but it seems that I missing something. thanks a lot Regards, andrea ##### CUT HERE ##### from pymol import cmd import string, sys, os def read_cluster(number): cmd.reinitialize() cmd.load('/home/pippo/ref.pdb','ref') cmd.select('Refactive','resi 17+20+23+25+26+43+44 in ref') HoL =3D {} FileToOpen =3D 'Dist' + number=20 DistOutput =3D open(FileToOpen,'w') DistOutput.write("ATOM_PROTEIN ATOM_LIGAND DISTANCE\n") out =3D open('cluster.out','r') pro_atoms =3D cmd.get_model("ref") # read cluster file for i in out.readlines(): i=3Dstring.strip(i) =20 tmp =3D string.split(i," ") index, elems =3D tmp[1], tmp[3:len(tmp)] =20 HoL[index] =3D elems # visualize the structures of cluster number for eachElem in HoL[number]: newElem =3D eachElem + '.pdb' cmd.load(newElem.strip(),eachElem) cmd.select('active','resi 17+20+23+25+26+43+44') cmd.select('lig','resn CBO') cmd.select('ligDon','(elem n,o and (neighbor hydro) in lig)') cmd.select('ligAcc','(elem o or (elem n and not (neighbor hydro)) in lig)') Don =3D cmd.select('don','(elem n,o and (neighbor hydro))') Acc =3D cmd.select('acc','(elem o or (elem n and not (neighbor hydr= o)))') # atoms_Don =3D cmd.index('don') # atoms_Acc =3D cmd.index('acc') HBA =3D cmd.distance('(lig and acc)','(active and don)',3.2) HBD =3D cmd.distance('(lig and don)','(active and acc)',3.2) cmd.align('ref',eachElem) DistOutput.write(" %14s %14s %8.3f\n"%(Don,Acc,HBA)) =20 DistOutput.close() =20 cmd.extend('read_cluster',read_cluster) ########## CUT HERE ################ |
From: Gilleain T. <gil...@ho...> - 2005-07-05 12:59:29
|
Hi, Well, the cmd.distance method seems to take minimum 4 parameters, not three: cmd.distance( string name, string selection1, string selection2, string cutoff, string mode ) where 'mode' is not important. So, in the script you give, the line: HBA = cmd.distance('(lig and acc)','(active and don)',3.2) could become HBA = cmd.distance('HBA', '(lig and acc)','(active and don)', 3.2) or, if you use the atom ids that you get from the (commented out) lines: atoms_Don = cmd.index('don') you could use cmd.get_distance in a loop: for donor in atoms_Don: for acceptor in atoms_Acc: DistOut.write("%s" % cmd.get_distance(donor, acceptor)) or something. gilleain torrance On 5/7/05 11:50, "Andrea Spitaleri" <and...@gm...> wrote: > Hi guys, > I am trying to make a script to automatize a procedure. I have got a > file where I can pick up the structure of protein-ligand complexes > cluster > The script below read the number of the cluster and then visualize > them align with a protein reference. Everything is fine except I'd > like write on a file the distances between some residues of each > structure with the ligand but I cannot figure out how do it. I read > different post but it seems that I missing something. > > thanks a lot > > Regards, > > andrea > > ##### CUT HERE ##### > from pymol import cmd > import string, sys, os > > def read_cluster(number): > cmd.reinitialize() > cmd.load('/home/pippo/ref.pdb','ref') > cmd.select('Refactive','resi 17+20+23+25+26+43+44 in ref') > HoL = {} > FileToOpen = 'Dist' + number > DistOutput = open(FileToOpen,'w') > DistOutput.write("ATOM_PROTEIN ATOM_LIGAND DISTANCE\n") > out = open('cluster.out','r') > pro_atoms = cmd.get_model("ref") > # read cluster file > for i in out.readlines(): > i=string.strip(i) > tmp = string.split(i," ") > index, elems = tmp[1], tmp[3:len(tmp)] > HoL[index] = elems > # visualize the structures of cluster number > for eachElem in HoL[number]: > newElem = eachElem + '.pdb' > cmd.load(newElem.strip(),eachElem) > cmd.select('active','resi 17+20+23+25+26+43+44') > cmd.select('lig','resn CBO') > cmd.select('ligDon','(elem n,o and (neighbor hydro) in lig)') > cmd.select('ligAcc','(elem o or (elem n and not (neighbor > hydro)) in lig)') > Don = cmd.select('don','(elem n,o and (neighbor hydro))') > Acc = cmd.select('acc','(elem o or (elem n and not (neighbor > hydro)))') > # atoms_Don = cmd.index('don') > # atoms_Acc = cmd.index('acc') > HBA = cmd.distance('(lig and acc)','(active and don)',3.2) > HBD = cmd.distance('(lig and don)','(active and acc)',3.2) > cmd.align('ref',eachElem) > DistOutput.write(" %14s %14s %8.3f\n"%(Don,Acc,HBA)) > > DistOutput.close() > > cmd.extend('read_cluster',read_cluster) > ########## CUT HERE ################ > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click > _______________________________________________ > PyMOL-users mailing list > PyM...@li... > https://lists.sourceforge.net/lists/listinfo/pymol-users > |
From: Andrea S. <and...@gm...> - 2005-07-05 14:17:13
|
> HBA =3D cmd.distance('HBA', '(lig and acc)','(active and don)', 3.2) yes thanks for the trick. However, I edited my script to: DistOutput.write(" %14s %14s %8s %8s\n"%("donor","acceptor","hba","hbd")) DistOutput.write(" %14s %14s %8.3f %8.3f\n"%(Don,Acc,HBA,HBD)) but I cannot figure out the meaning of the output: complex_1 donor acceptor hba hbd 260 271 2.536 -1.000 complex_2 donor acceptor hba hbd 391 409 2.489 -1.000 complex_3 donor acceptor hba hbd 522 547 2.512 -1.000 complex_4 donor acceptor hba hbd 653 685 2.456 -1.000 what the numbers under donor and acceptor are? >=20 > atoms_Don =3D cmd.index('don') >=20 I tried also this option and it works fine (more or less) excet that it takes a lot time to calculate all the distance (quite weird on my dual-cpu 3Gz intel) this is the loop used: for donor in atoms_Don: for acceptor in atoms_Acc: di =3D cmd.get_distance("%s`%d"%donor,"%s`%d"%acceptor) DistOutput.write("%8s %8s %8.3f\n"%(donor,acceptor,di)) thanks Regards andrea |
From: Gilleain T. <gil...@ho...> - 2005-07-05 23:13:05
|
Hi, I suppose that these numbers are the atom_ids. It's probably the same numbers returned by the cmd.index function. I guess you could test this by typing "select atom260, id 260" and see if that makes a selection with atom260... As for the speed question, I have no idea. More of a question for Mr DeLano :) Calculating pairwise like this is always going to be computationally expensive, but I don't know ways to speed this up. gilleain torrance On 5/7/05 15:17, "Andrea Spitaleri" <and...@gm...> wrote: >> HBA = cmd.distance('HBA', '(lig and acc)','(active and don)', 3.2) > yes thanks for the trick. However, I edited my script to: > DistOutput.write(" %14s %14s %8s %8s\n"%("donor","acceptor","hba","hbd")) > DistOutput.write(" %14s %14s %8.3f %8.3f\n"%(Don,Acc,HBA,HBD)) > but I cannot figure out the meaning of the output: > complex_1 > donor acceptor hba hbd > 260 271 2.536 -1.000 > complex_2 > donor acceptor hba hbd > 391 409 2.489 -1.000 > complex_3 > donor acceptor hba hbd > 522 547 2.512 -1.000 > complex_4 > donor acceptor hba hbd > 653 685 2.456 -1.000 > what the numbers under donor and acceptor are? > >> >> atoms_Don = cmd.index('don') >> > > I tried also this option and it works fine (more or less) excet that > it takes a lot time to calculate all the distance (quite weird on my > dual-cpu 3Gz intel) > this is the loop used: > for donor in atoms_Don: > for acceptor in atoms_Acc: > di = cmd.get_distance("%s`%d"%donor,"%s`%d"%acceptor) > DistOutput.write("%8s %8s %8.3f\n"%(donor,acceptor,di)) > > thanks > > Regards > > andrea > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click > _______________________________________________ > PyMOL-users mailing list > PyM...@li... > https://lists.sourceforge.net/lists/listinfo/pymol-users > |
From: Andrea S. <and...@gm...> - 2005-07-06 09:06:03
|
Hi thanks for your reply. Yes it is the id. I found out also that it takes a lot time because is looping in all atoms and in the "active" site. So I fixed that. Anyway more in general, I saw that the manual is lacking of some information useful for who wants to program. I mean, sometimes it doesn't say if a command returns a tuple or a list or a dictionary. Ex: cmd.index("selection") is a list? thanks Regards, andrea 2005/7/6, Gilleain Torrance <gil...@ho...>: > Hi, >=20 > I suppose that these numbers are the atom_ids. It's probably the same > numbers returned by the cmd.index function. >=20 > I guess you could test this by typing "select atom260, id 260" and see if > that makes a selection with atom260... >=20 > As for the speed question, I have no idea. More of a question for Mr DeLa= no > :) Calculating pairwise like this is always going to be computationally > expensive, but I don't know ways to speed this up. >=20 > gilleain torrance >=20 >=20 > On 5/7/05 15:17, "Andrea Spitaleri" <and...@gm...> wrote: >=20 > >> HBA =3D cmd.distance('HBA', '(lig and acc)','(active and don)', 3.2) > > yes thanks for the trick. However, I edited my script to: > > DistOutput.write(" %14s %14s %8s %8s\n"%("donor","acceptor","hba","hbd= ")) > > DistOutput.write(" %14s %14s %8.3f %8.3f\n"%(Don,Acc,HBA,HBD)) > > but I cannot figure out the meaning of the output: > > complex_1 > > donor acceptor hba hbd > > 260 271 2.536 -1.000 > > complex_2 > > donor acceptor hba hbd > > 391 409 2.489 -1.000 > > complex_3 > > donor acceptor hba hbd > > 522 547 2.512 -1.000 > > complex_4 > > donor acceptor hba hbd > > 653 685 2.456 -1.000 > > what the numbers under donor and acceptor are? > > > >> > >> atoms_Don =3D cmd.index('don') > >> > > > > I tried also this option and it works fine (more or less) excet that > > it takes a lot time to calculate all the distance (quite weird on my > > dual-cpu 3Gz intel) > > this is the loop used: > > for donor in atoms_Don: > > for acceptor in atoms_Acc: > > di =3D cmd.get_distance("%s`%d"%donor,"%s`%d"%acceptor) > > DistOutput.write("%8s %8s %8.3f\n"%(donor,acceptor,di)) > > > > thanks > > > > Regards > > > > andrea > > > > > > ------------------------------------------------------- > > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > > from IBM. Find simple to follow Roadmaps, straightforward articles, > > informative Webcasts and more! Get everything you need to get up to > > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dclick > > _______________________________________________ > > PyMOL-users mailing list > > PyM...@li... > > https://lists.sourceforge.net/lists/listinfo/pymol-users > > >=20 > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dclic= k > _______________________________________________ > PyMOL-users mailing list > PyM...@li... > https://lists.sourceforge.net/lists/listinfo/pymol-users > |