Skip to content

TorchProteinLibrary 0.2 Nucleic Acid Extension #39

Open
fmatreale wants to merge 372 commits intomasterfrom
na
Open

TorchProteinLibrary 0.2 Nucleic Acid Extension #39
fmatreale wants to merge 372 commits intomasterfrom
na

Conversation

@fmatreale
Copy link
Collaborator

TorchProteinLibrary 0.2 Nucleic Acid Extension

removed test file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this PR, let's revert to the original version

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Is this a fix for the "master" branch or something you needed for the "dev branch? In other words, is it going to break the "master" code if we don't use your local version of CUSP?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we just need a version of CUSP in the TPL directory when it's compiled locally.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In function "Angles2Coords_forward", you have two "if" blocks (polymer_type 0 and polymer_type 1 or 2) but it seems the code is identical except for "<8" for proteins and "<10" for nucleic acids. So you can use the "if" clause for that little piece of code only:

if(polymer_type == 0){
if( length<seq.length() || single_angles.sizes()[0]<8 ){
ERROR("incorrect angles tensor length");
}
} else if(polymer_type == 1 or polymer_type == 2) {
if( length<seq.length() || single_angles.sizes()[0]<10 ){
ERROR("incorrect angles tensor length");
}
}

That way, no need to duplicate the code.

As far as I can see, the call to function "ProtUtil::getNumAtoms(seq, add_terminal)" for proteins can be replaced by the version you have for nucleic acids: "ProtUtil::getNumAtoms(seq, add_terminal, polymer_type, chain_names)".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of duplicated code between the "protein" and the "nucleic acid" parts... If anything can be done to reduce the redundancy (without compromising the readability), that would be an improvement

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of C++ indentation issues...

Also, whenever you have a series of mutually exclusive "if" clauses, you're better with either the "switch-case" construct "if else if else if" construct. Faster and cleaner...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to keep the old values in the code -- just commented out.

Provide the DOIs of the articles in the comments, though:
PeptideBuilder: DOI:10.7717/peerj.80
Engh and Huber: DOI:10.1107/S0108767391001071

By the way, some of the values are quite different between the two. Were some of these bugs? Make sure you are not introducing a bug yourself, @fmatreale

As always, fix the indentation...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the indentation...

I don't understand what the "model_count" variable is doing. Why do you read the data only if "model_count" is 1.

As usual, try to remove the duplicate code between the protein case, the RNA case, and the DNA case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a benchmark for code that's already in TPL, so it can be merged.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not a change we need for nucleic acids. Revert to the original master branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz, what should we keep from these changes if we don't want the "Physics" code yet? Is "Volume/VolumeMultiplication" ready for release? What about "Utils/Protein" and "Utils/Volume"? If you could make a version of that file that we can use for release, that would be appreciated :-)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz It doesn't look like it's ready for release. Can you confirm that it's OK to not include that whole file for the time being? (along with the ".h" file, I guess)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz For that whole Kernel/HashKernel issue, can you modify the code in the "na" branch so that it can be merged to the "master" branch? It seems this code still belongs just to "dev"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz For that whole Kernel/HashKernel issue, can you modify the code in the "na" branch so that it can be merged to the "master" branch? It seems this code still belongs just to "dev"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz What is "SelectVolume" doing? Should we merge it to "master"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz What is "SelectVolume" doing? Should we merge it to "master"?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Georgy, can you confirm that the "Coords2Elect" code can be removed from the "na" branch? @fmatreale can take care of that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Georgy, can you confirm that the "Coords2Elect" code can be removed from the "na" branch? @fmatreale can take care of that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Georgy, can you confirm that the "Coords2Stress" code can be removed from the "na" branch? @fmatreale can take care of that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Georgy, can you confirm that the "Coords2Stress" code can be removed from the "na" branch? @fmatreale can take care of that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Remove from the "na" branch. It's definitely not something we need to merge to "master".

Copy link
Collaborator

@glamoure glamoure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale, unless Georgy confirms that the new "HashKernel" code is working, would you mind reverting to the original?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Is that code ready for release? In other words, is the "HashKernel" code ready?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, check the latest commit to the dev branch. It compiles and to test HashKernel you can:

cd UnitTests/Volume/TypedCoords2Volume
python test_forward.py

afterwards, you'll have xplor in UnitTests/Volume/TypedCoords2Volume/TestFig. However I can't guarantee correctness of backward pass. You can try to test it yourself, but I recommend overwriting everything.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Is that code ready for release? In other words, is the "HashKernel" code ready?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Is this code ready for release?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lupoglaz Is this code ready for release?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Can you clarify the comments? These are Python reimplementations of some C++ functions, right?

}


// AS: Need transformation matrices (setDihedral,setDihedralDphi,setDihedralDpsi,setDihedralDr, setRx, setRy, setRz, setDRx)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anushriya This comment can be removed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file even needed?

if polymer_type == 1 or polymer_type == 2:
ctx.save_for_backward(input_angles_cpu, sequenceTensor, torch.tensor(polymer_type, dtype=torch.int32), chain_names)
input_angles_cpu = input_angles_cpu.contiguous()
max_num_atoms = num_atoms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not "torch.max(num_atoms)" like for polymer_type 0? This code assumes "num_atoms" is a single number, not an array.

'''Converts a string to 0-terminated byte tensor'''
return torch.from_numpy(np.fromstring(string+'\0', dtype=np.uint8))

def convert2str(tensor):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function needed? I don't see it being called anywhere in that file. (Somewhere else, maybe?)

current_residue.add(atom)

if polymer_type == 2:
if len(atom_name) == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed only for polymer_type 2?


if polymer_type == 1 or polymer_type == 2:
# print(str(residue)[10])
if str(residue)[10] == 'A' or str(residue)[9] == 'A':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the best way to implement this? Why is it sometimes at position 9 and sometimes at position 10?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the "physics" addition. Do not include

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the "physics" addition. Do not include

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the "physics" addition. Do not include

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this file in the repo?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Revert to "master" branch version

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmatreale Not needed, since we don't merge that code in the "master" branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants