MonZop / BioBlender

AddOn for Blender to do molecular work
BSD 2-Clause "Simplified" License
113 stars 20 forks source link

Do all test molecules import correctly in Blender 2.68? #8

Closed zeffii closed 9 years ago

zeffii commented 9 years ago

In the 273_Compatible branch, the following test molecules import OK. But very slow for reasons which are known

in 2.73+ currently the imports look as follows:

[01_CaM_Protein3Conformations_wH.PDB]()

image

no errors!


[02_4IHV_dsDNA.pdb]() Fixed!

image

with this abbreviated output

DA
---calculating----
parent
["C1'", 'C']
returned
Import Failed: ('Unable to generate all bonds and constraints:', NameError("name 'modelList' is not defined",))

remark: Here the reference to modelList comes from nowhere, Do you know what it should reference? The term modelList only occurs 2 times in the whole of BioBlender2.py, but doesn't seem to be assigned at any point. Perhaps that should be tmpModel instead?

edit: after test replacing modelList with tmpModel it is evident that that wasn't a simple typo.

https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L947-L952 (references modelList) . ~~but a few lines up from it the same mechanism references tmpModel instead . https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L915-L922~~


[03_3IV5_DNA_proteinComplex.pdb]() Fixed!

image

error abbreviated:

parent
["C1'", 'C']
returned
Import Failed: ('Unable to generate all bonds and constraints:', NameError("name 'modelList' is not defined",))

again with reference to modelList


[04_Dimer_1A4U.pdb]()

image

this takes a catastrophic 3 minutes, but no errors


[05_glycoprotein_4AY9_FSH.pdb]()

image

no errors


[06PLipid.pdb]()

image

error abbreviated:

appending file
core_create_Models
Import Failed: ('Unable to generate all bonds and constraints:', UnboundLocalError("local variable 'parent' referenced before assignment",))

remark, exceptions without line-numbers are annoying. I will add this feature eventually, but here it might be ok to assume that wherever parent is assigned a value, that code isn't actually executed, one of the loops where this happens probably doesn't loop over anything. After adding line numbers to exception handling, it appears that the bondLookUp for a specific atom fails to produce a parent, and that's why parent is referenced before assignment. See further down for more about this error

https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L924-L952

MonZop commented 9 years ago

I'm checking all the pdb files with previous BioBlender. If necessary, I will adjust the files to make them readable.

MonZop commented 9 years ago

The PDB files 02_4IHV_dsDNA and 03_3IV5_DNA_proteinComplex have the same problem: thay fail to build the DNA bases. I have changed the file 02, to make it simpler (but with same problems), and faster to test.

zeffii commented 9 years ago

May I suggest if you edit a pdb , that you suffix the name with EDITED or REDUX, and keep the originals to test against?

zeffii commented 9 years ago

At the moment I don't know where the reference to modelList comes from, can we ask the coder what the intention of https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L947-L952 was?

zeffii commented 9 years ago

@MonZop OK i downloaded version BioBlender1.0 and in BB267___PDBimport.py I see in: core_parsePDB(filePath), there's a global modelList, and quite a number of other references to it :) At least I will know where to start unraveling it, if they can't offer help at the moment.

zeffii commented 9 years ago

Progress! image

                        if targetKey == "atom":
                            print("TargetKey not set, will skip Rigid Body Joint")
                        else:
                            obj = bpy.data.objects[entry[0]]

                            # line = modelList[0][entry[0]]
                            line = tmpModel[entry[0]]

                            obj.location=line.get("loc")

                            # line = modelList[0][targetKey]
                            line = tmpModel[targetKey]

                            nextEntry.location=line.get("loc")
                            addRigidBodyRotamer(obj,bpy.data.objects[targetKey])
MonZop commented 9 years ago

Good! Do I understand that the molecule is built, but without the joints?

zeffii commented 9 years ago

Good question, with that portion of the code now seemingly doing what it was supposed to i'll continue with the differential of BB1 and BB2.

Maybe you could try the 273_compatibility branch, are you familiar with how to try various branches of the same repository?

zeffii commented 9 years ago

06PLipid.pdb

not yet fixed.

After adding Line / Line number messages to the Exception handling In my branch, there is more information.

Traceback (most recent call last):
  File "C:\......\BioBlender\BioBlender2.py", line 919, in core_createModels
    parent = bondLookUp(atom=atom, amac=amac)
  File "C:\......\BioBlender\BioBlender2.py", line 1060, in bondLookUp
    return parent
UnboundLocalError: local variable 'parent' referenced before assignment

Import Failed: ('Unable to generate all bonds and constraints:', UnboundLocalError("local variable 'parent' referenced before assignment",))

it seems in bondLookUp it fails to find a reference, what to do if bondLookUp finds no bonds? @MonZop maybe it's that one file which demonstrates missing entries in the bondLookUp function? atom, amac = C11, POP this combo is not found. specifically

['POP', '2', 'C11', 'X', 'C']
C11 POP

is POP http://www.rcsb.org/pdb/ligand/ligandsummary.do?hetId=POP&sid=1cjb ( PYROPHOSPHATE 2- )

zeffii commented 9 years ago

@MonZop in the pdb , excerpt below

ATOM     61  H11 POP X   2      12.954   4.010  20.151  0.00  0.00           H 
ATOM     62  H12 POP X   2      12.908   4.056  18.346  0.00  0.00           H 
ATOM     63  H21 POP X   2      11.094   2.474  18.302  0.00  0.00           H 
ATOM     64  H22 POP X   2      11.134   1.252  19.780  0.00  0.00           H 
ATOM     65  H23 POP X   2      11.191   3.034  20.030  0.00  0.00           H 
ATOM     66  H31 POP X   2      12.983   0.382  20.400  0.00  0.00           H 
ATOM     67  H32 POP X   2      14.549   1.235  20.254  0.00  0.00           H 
ATOM     68  H33 POP X   2      13.140   1.903  21.321  0.00  0.00           H 
ATOM     69  H41 POP X   2      14.428   1.197  18.028  0.00  0.00           H 
ATOM     70  H42 POP X   2      12.912   0.353  18.102  0.00  0.00           H 
ATOM     71  H43 POP X   2      13.118   1.979  17.072  0.00  0.00           H 

H 11, 12, 21, 22, 23, 31, 32, 33, 41, 42, 43 all refer to the quantized state of a H atom?

zeffii commented 9 years ago

OK, this section of the code is identical to the BioBlender1.0 ( http://www.bioblender.eu/Database/BB267.zip ) maybe it's time to look at the source of BioBlender 0.6.

MonZop commented 9 years ago

The P_lipid is a phopspho-lipid, it has two carbon chains conncted at the head with a group containing a phosphorus atom and several oxygens (my apologies to any chemist that may read this). I suspect that the reason why it fails to import is that in the bonds library it is not listed. Before BB2, the chemical bonds were included only on request.

zeffii commented 9 years ago

Maybe you could describe the process of adding bonds to the bondLookUp function. Knowing how this works might let me automate the process. Possibly from a library? I imagine such library does exist but it may be big?

MonZop commented 9 years ago

Sorry, I do not even understand the question: but it may help if I add the lipid to the library?

zeffii commented 9 years ago

yep. perfect (I have since edited that question, I hope it is clearer to potential on-lookers)

MonZop commented 9 years ago

My understading is that the bonds are considered of two tipes: MainChain and SideChain (or Amino-acid, Amac). The bonds of the main chain are easy to build because they are linear: for proteins it is a single chain of bonds connecting the atoms designed as (N, CA, C)n in a single row; for nucleic acids it is also a single chain of bonds, which connect atoms designed as (P, O5', C5', C4', C3', O3')n. The main chain is defined (I think) in the main program (BioBlender2.py).

Next are the SideChians: for proteins there are 20 different AminoAcids (Ala, Arg,Asn, Asp etc.). They invariably start with a CB, bound to the corresponding CA, and proceed in various combiantion of atoms. For Nucleic Acids, they are the 4 Basis (ACTG) + U, and stem from C3' and proceed with C2' etc.. For what I recall, the specific bonds of the side chains were all stored in a library (which I cannot locate in the BioBlender folder, maybe you do?).

The Lipid is not considered (yet). I suggest that we concentrate for now on proteins and nucleic acids, and reconsider how to deal with lipids for a following time. I will remove the P_lipid file from the TestMolecules folder, in order to avoid confusion.

zeffii commented 9 years ago

These are the only lookups I see: https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L186-L224 <-- perhaps? https://github.com/MonZop/BioBlender/blob/master/BioBlender2.py#L976-L1070

OK i will ignore the Lipid.

MonZop commented 9 years ago

FOUND! The first part (L186-L224) define the value of the lipophilic potential for each atom (not relevant here), but the seond is exactly the bond connections. To make a general structure for lipids is more complex, because they are not as modular as proteins and nucelic acids. Let's just ignore for now, and/or set BB to build the molecule with atoms but without joints (bonds).

zeffii commented 9 years ago

I think all bones are created, at least this feature doesn't appear to be broken from what I can make out.

zeffii commented 9 years ago

The imports do seem to work, given restrictions. Bones / Joints should be a separate issue or more specific issue

zeffii commented 9 years ago

The imports do seem to work, given restrictions. Bones / Joints should be a separate issue or more specific issue