Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
372 commits
Select commit Hold shift + click to select a range
cc66377
Updated PDBLoader
fmatreale Sep 13, 2022
4aa229d
Updated PDBLoader
fmatreale Sep 13, 2022
815efcc
Updated PDBLoader
fmatreale Sep 13, 2022
16d0af5
Updated PDBLoader
fmatreale Sep 13, 2022
e7e69f1
Updated PDBLoader
fmatreale Sep 13, 2022
180468c
Updated PDBLoader
fmatreale Sep 13, 2022
ca80801
Updated PDBLoader
fmatreale Sep 13, 2022
d2ba39b
Updated PDBLoader
fmatreale Sep 13, 2022
db20cba
Updated PDBLoader
fmatreale Sep 14, 2022
ecd639a
Updated PDBLoader
fmatreale Sep 14, 2022
31be54a
Updated PDBLoader
fmatreale Sep 14, 2022
bb77dcd
Updated PDBLoader
fmatreale Sep 14, 2022
d74a584
Updated PDBLoader
fmatreale Sep 14, 2022
67634de
Updated PDBLoader
fmatreale Sep 14, 2022
e28b2cb
Updated PDBLoader
fmatreale Sep 14, 2022
88a6392
Updated PDBLoader
fmatreale Sep 14, 2022
a690ec4
Updated PDBLoader
fmatreale Sep 15, 2022
d114d4f
Updated PDBLoader
fmatreale Sep 15, 2022
deb2697
Updated PDBLoader
fmatreale Sep 15, 2022
f621ce0
Updated PDBLoader
fmatreale Sep 19, 2022
8fde8a2
Updated PDBLoader and Coords2Angles.py
fmatreale Sep 19, 2022
19eeb09
Updated Coords2Angles.py
fmatreale Sep 19, 2022
3d01fc0
Updated Coords2Angles.py
fmatreale Sep 27, 2022
db61bea
PDB2Coords.py writePDB test
fmatreale Sep 27, 2022
f8f6d68
PDB2Coords.py writePDB test
fmatreale Oct 4, 2022
4c07845
PDB2Coords.py writePDB test
fmatreale Oct 11, 2022
a7dd4c5
PDB2Coords.py writePDB test
fmatreale Oct 11, 2022
cfdc0f3
PDB2Coords.py writePDB test
fmatreale Oct 11, 2022
489dbab
Coords2Angles Test
fmatreale Oct 12, 2022
af7d684
Coords2Angles Test
fmatreale Oct 13, 2022
52ac4ea
Coords2Angles Test
fmatreale Oct 13, 2022
0c30558
cPDBLoader Test
fmatreale Oct 15, 2022
aa2a6c5
cPDBLoader Test
fmatreale Oct 15, 2022
729f832
cPDBLoader Test
fmatreale Oct 16, 2022
2119094
cPDBLoader Test
fmatreale Oct 16, 2022
116e915
cPDBLoader Test
fmatreale Oct 16, 2022
9f9f1a2
pdb2Coords: update polymertype 1 for new chain O5' index
fmatreale Nov 9, 2022
3e5123a
pdb2Coords: update polymertype 1 for new chain O5' index
fmatreale Nov 9, 2022
fdb65dd
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
30393e7
pdb2Coords: chain name test
fmatreale Nov 9, 2022
954338e
pdb2Coords: chain name test
fmatreale Nov 9, 2022
00d0edf
pdb2Coords: chain name test
fmatreale Nov 9, 2022
bce45f3
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
70ed719
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
3f49736
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
c7b92ab
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
04a9692
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
31075b2
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
965406f
pdb2Coords: update O5' index
fmatreale Nov 9, 2022
9c994c1
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
46fa78c
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
2ab5655
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
d31268a
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
108c2d4
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
ac20ac5
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
1164fac
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
9a0f2e4
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
60dacd8
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
3b2be2d
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
0cf8019
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
22e65b2
pdb2Coords: update O5' index
fmatreale Nov 10, 2022
88f2b4f
pdb2Coords: update O5' index
fmatreale Nov 11, 2022
594bbd6
pdb2Coords: update O5' index
fmatreale Nov 11, 2022
9a0e859
pdb2Coords: update O5' index
fmatreale Nov 11, 2022
7d153c1
pdb2Coords: update O5' index
fmatreale Nov 16, 2022
a150189
pdb2Coords: update O5' index
fmatreale Nov 16, 2022
c90e505
pdb2Coords: test O5' index
fmatreale Nov 16, 2022
babaa30
pdb2Coords: test O5' index
fmatreale Nov 16, 2022
41551a6
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
5e60db0
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
b06d5f0
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
90f63f5
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
4998cde
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
b924391
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
4bb46e6
pdb2Coords: update O5' index
fmatreale Nov 18, 2022
bc93e1c
Utils: update get atom index
fmatreale Nov 18, 2022
815503e
Utils: update get atom index
fmatreale Nov 18, 2022
3447d41
Utils: update get atom index
fmatreale Nov 18, 2022
4785b0d
Utils: update get atom index
fmatreale Nov 18, 2022
e651a7a
Utils: update get atom index
fmatreale Nov 19, 2022
ddb70c7
Utils: update get atom index
fmatreale Nov 19, 2022
75d4ad3
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
8760b6e
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
d9cc9b6
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
551fa42
Util: update get atom index
fmatreale Nov 19, 2022
abaceb8
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
772fa5f
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
42cd22a
PDB2coords: update na pdbloader call
fmatreale Nov 19, 2022
6b29a51
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
4830c5c
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
984df92
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
e172f3d
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
643c8fb
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
5fd3ddd
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
4d83013
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
ebaf4c3
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
20816d7
PDBLoader: test
fmatreale Nov 20, 2022
2311b10
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
207ffb9
PDB2coords: update na pdbloader call
fmatreale Nov 20, 2022
feb4a9b
PDB2coords: update writePDB
fmatreale Nov 20, 2022
3a4389f
PDB2coords: update writePDB
fmatreale Nov 20, 2022
e4ee2a7
Coords2Angles: update na call
fmatreale Nov 20, 2022
ef3ea76
Coords2Angles: update getBackbone and getRotamer
fmatreale Jan 3, 2023
a19d87e
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
fac18fc
Coords2Angles: update BioStructure2Dihedrals and getBackbone
fmatreale Jan 3, 2023
6302c4f
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
12f80d0
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
27ba0e5
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
c15bc3a
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
e410d1d
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
9b59ad0
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
77a7870
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
9e4077a
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
028a450
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
24b11d7
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
697f2a8
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
fe4de46
Coords2Angles: update getBackbone
fmatreale Jan 3, 2023
c778a94
Coords2Angles: update getBackbone
fmatreale Jan 4, 2023
0a68d0d
Coords2Angles: update getBackbone
fmatreale Jan 4, 2023
41832db
Coords2Angles: update getBackbone
fmatreale Jan 4, 2023
a80523c
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
4874d25
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
48790b3
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
f77b944
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
826a557
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
2d1fb5f
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
a742d39
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
4c23b01
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
2c33bf9
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
41b041d
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
c3a371c
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
01f7725
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
2dbe19e
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
54b569b
Coords2Angles: update getBackbone
fmatreale Jan 5, 2023
bdccf44
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
70ae828
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
0517375
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
ac41953
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
b03f826
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
2eeaf4c
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
dfa81c8
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
3f666c3
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
dca6aee
Coords2Angles: update getRotamer
fmatreale Jan 5, 2023
e8a4d7d
Coords2Angles: update coords2angles
fmatreale Jan 5, 2023
baf0979
Coords2Angles: update coords2angles function
fmatreale Jan 17, 2023
1d37b4f
Conformation: changed add... (NAres) for test
fmatreale Jan 17, 2023
fbef4b3
Conformation: added polymer_type argument
fmatreale Jan 17, 2023
f0481dc
Conformation: added polymer_type argument
fmatreale Jan 17, 2023
a9ff06c
Conformation: added polymer_type argument
fmatreale Jan 17, 2023
6b89445
angles2coords_interface: added NAnumAtoms argument
fmatreale Jan 17, 2023
f302796
angles2coords_interface: added polymer_type
fmatreale Jan 17, 2023
1e6f3bc
angles2coords_interface: added polymer_type
fmatreale Jan 17, 2023
5be97ff
angles2coords: changed default of polymer_type
fmatreale Jan 19, 2023
b14b711
angles2coords: changed default of NA_num_atoms
fmatreale Jan 19, 2023
3efbb44
angles2coords_interface: added num_atoms test
fmatreale Jan 19, 2023
357cf47
angles2coords_interface: added num_atoms test
fmatreale Jan 19, 2023
ad3587a
angles2coords_interface: added num_atoms test
fmatreale Jan 19, 2023
0891453
angles2coords_interface: added num_atoms test
fmatreale Jan 19, 2023
298b667
angles2coords_interface: added num_atoms test
fmatreale Jan 19, 2023
1d21d17
angles2coords_interface: added num_atoms test
fmatreale Jan 21, 2023
7aab440
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
d17fff2
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
52316b3
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
59b8956
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
78eb88a
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
3c54a1e
angles2coords_interface: modified num_atoms test
fmatreale Jan 21, 2023
dbc83b4
angles2coords: modified polymer_type test
fmatreale Jan 21, 2023
db93e51
Coords2Angles: nan -> 0.0
fmatreale Jan 21, 2023
7fa1c7b
Angles2Coords: modified Function call
fmatreale Jan 21, 2023
6c693a1
Angles2Coords: modified Function call
fmatreale Jan 21, 2023
f25debd
angles2coords_interface: modified getNumAtoms call
fmatreale Jan 21, 2023
c148429
nUtil: added polymer type to getNumAtoms
fmatreale Jan 21, 2023
48bdca2
nUtil: added polymer type to getNumAtoms
fmatreale Jan 21, 2023
0420d47
nUtil: added polymer type to getNumAtoms
fmatreale Jan 21, 2023
1b5f32c
angles2coords_interface: modified save to test
fmatreale Jan 21, 2023
6637122
angles2coords_interface: modified save to test
fmatreale Jan 21, 2023
4c36152
angles2coords_interface: modified save to test
fmatreale Jan 21, 2023
de11b82
Util: updated getAtomIndex
fmatreale Jan 22, 2023
6a7e462
Util: updated getAtomIndex
fmatreale Jan 22, 2023
0004f56
Util: updated getNumAtoms
fmatreale Jan 22, 2023
b941c26
angles2coords_interface: updated polymer_type = 1
fmatreale Jan 23, 2023
d80746c
Util: updated getNumAtoms
fmatreale Jan 23, 2023
04855d4
ConformationAA: added addDG,DA, DC, and DT
fmatreale Jan 31, 2023
e1dec82
Conformation: add Nucleic acid residues(addDG,...)
fmatreale Feb 28, 2023
5d0779d
Conformation: modified add Nucleic acid residues(addDG,...) and add_a…
fmatreale Feb 28, 2023
fd4ad7e
Conformation: modified add Nucleic acid residues function (addDG,...)
fmatreale Feb 28, 2023
1c2dc07
Conformation: modified add Nucleic acid residue functions (addDG,...)…
fmatreale Feb 28, 2023
ad3ec46
Conformation: modified add Nucleic acid residue functions (addDG,...)
fmatreale Mar 2, 2023
52ad974
angles2coords_interface: modify num_atoms for test
fmatreale Mar 2, 2023
62b4417
angles2coords_interface: modify num_atoms for test
fmatreale Mar 2, 2023
1786cb7
angles2coords_interface: modify num_atoms for test
fmatreale Mar 2, 2023
7f3dd35
angles2coords_interface: modify num_atoms for test
fmatreale Mar 2, 2023
20754c0
angles2coords_interface: modify num_atoms for test
fmatreale Mar 2, 2023
012843d
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
37dd2e9
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
c2ff830
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
36a551a
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
12dd9b6
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
c4e2bef
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
bca7d6d
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
dfbc047
angles2coords_interface: modify num_atoms for test
fmatreale Mar 7, 2023
7e3e650
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
8ebf85f
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
a614cf1
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
194909d
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
7c5bb3e
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
4f84324
angles2coords: modify num_atoms for test
fmatreale Mar 7, 2023
88f914d
angles2coords_interface: modify backward num_atoms for test
fmatreale Mar 8, 2023
f10b089
ConformationAA: modify ADDPHOSPHATE for test
fmatreale Mar 8, 2023
15dabb3
Angles2Coords: modified forward call for test
fmatreale Mar 8, 2023
c5de12e
Angles2Coords_interface: add print statement as test
fmatreale Apr 6, 2023
5c60396
Angles2Coords_interface: removed print statement
fmatreale Apr 6, 2023
3adc58c
Conformation: modified test print statement
fmatreale Apr 6, 2023
6fa21da
Conformation: modified test print statement
fmatreale Apr 6, 2023
9f1d3eb
ConformationAA: added test print statement
fmatreale Apr 6, 2023
68af3f5
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
ec97ae7
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
a046100
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
28f4d41
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
e1f726d
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
ef7c0a2
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
abc7d85
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
561865d
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
6630c51
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
efb2a6e
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
4ea9970
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
0372e23
ConformationAA: modified test print statement
fmatreale Apr 6, 2023
ca125ee
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
1b4b6f1
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
e10c8a2
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
63181b3
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
5782bec
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
22df1c0
ConformationAA: modified test print statement
fmatreale Apr 11, 2023
9a27f6d
ConformationAA: modified test print statement
fmatreale Apr 14, 2023
270af11
ConformationAA: modified ADD_NAatoms fixed add node
fmatreale Apr 14, 2023
5ea5d96
Conformation: modified print statement
fmatreale Apr 14, 2023
8a4c59e
angles2coords_interface: updated convertRes1to3 init
fmatreale Apr 14, 2023
cb85868
angles2coords: updated num_atoms
fmatreale Apr 15, 2023
c76a526
angles2coords: added chain_names arg and modified num_atoms
fmatreale May 16, 2023
f06a152
angles2coords: added chain_names arg and called getNumAtoms
fmatreale Aug 1, 2023
28623f2
Angles2Coords: added polymer type 2 and fixed backward call for poly …
fmatreale Feb 6, 2024
70e99a9
Conformation: removed test print statements
fmatreale Feb 14, 2024
c7527ea
Angles2Coords: removed test print statements
fmatreale Mar 15, 2024
f20467d
Angles2Coords: saved polymer_type and chain_name as tensors for backw…
fmatreale Mar 23, 2024
9b1b007
Update README.md
glamoure Jun 18, 2024
7e73d9b
Refactoring Examples
fmatreale Jun 19, 2024
6db5bec
Removed Unnecessary Comments
fmatreale Jun 20, 2024
384bac4
testing
Jun 20, 2024
fddcd34
Merge remote-tracking branch 'origin/na' into na
fmatreale Jun 20, 2024
8819d48
Delete na/test_git.sh
anushriya Jun 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
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

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
*.sty
*.gif
*.txt
*.crg
*.siz
*.cube
*.vscode
build/*
dist/*
*/talled
*.mp4

#Python
*.pyc
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cusplibrary"]
path = cusplibrary
url = https://github.com/lupoglaz/cusplibrary.git
branch = develop
64 changes: 64 additions & 0 deletions Benchmark/volumemul.py
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from core import ModuleBenchmark
import torch
from torch.autograd import profiler
from TorchProteinLibrary import VolumeMul

import numpy as np
import seaborn as sea
from matplotlib import pylab as plt
import pandas as pd
from tqdm import tqdm
import pickle as pkl

class VolumeMulBenchmark(ModuleBenchmark):
def __init__(self, device='gpu', num_sequences=32, seq_length=350):
super().__init__(device)
self.vol1 =

def prepare(self):
self.angles.requires_grad_()
self.coords = self.module(self.angles, self.length)
self.grad_coords = torch.ones(self.coords.size(), dtype=torch.float, device='cuda')

def run_forward(self):
self.angles.detach()
self.coords = self.module(self.angles, self.length)

def run_backward(self):
self.coords.backward(self.grad_coords)

def test_length( interval=(60, 20, 300), num_measurements=1, output_filename='length.dat'):
time = []
direction = []
length = []
for n in range(num_measurements):
for i in tqdm(range(interval[0], interval[2], interval[1])):
mb = Angles2BackboneBenchmark(seq_length=i)
dur_fwd = mb.measure_forward()
time.append(dur_fwd/1000.0)
direction.append('Forward')
length.append(i)
dur_bwd = mb.measure_backward()
time.append(dur_bwd/1000.0)
direction.append('Backward')
length.append(i)

data = pd.DataFrame({ 'Time': time,
'Direction': direction,
'Length': length
})
data.to_pickle(output_filename)

if __name__=='__main__':

test_length(interval=(60, 20, 700), output_filename='Data/ReducedModelTime.pkl', num_measurements=10)

data = pd.read_pickle('Data/ReducedModelTime.pkl')
sea.set_style("whitegrid")
sea.set_context("paper", font_scale=1.5, rc={"lines.linewidth": 1.5})
g1 = sea.relplot(x="Length", y="Time", hue='Direction', kind="line", style="Direction", height=6, aspect=1.3, markers=True, data=data)
plt.ylabel("Time, ms")
plt.xlabel("Sequence length, amino-acids")
sea.despine()
# plt.show()
plt.savefig("Fig/ReducedModelTime.png")
176 changes: 122 additions & 54 deletions Layers/FullAtomModel/Angles2Coords/angles2coords_interface.cpp
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)".

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ void Angles2Coords_forward( torch::Tensor sequences,
torch::Tensor input_angles,
torch::Tensor output_coords,
torch::Tensor res_names,
torch::Tensor atom_names
torch::Tensor res_nums,
torch::Tensor atom_names,
int polymer_type,
torch::Tensor chain_names
){
bool add_terminal = false;
CHECK_CPU_INPUT_TYPE(sequences, torch::kByte);
Expand All @@ -23,60 +26,122 @@ void Angles2Coords_forward( torch::Tensor sequences,
}

int batch_size = input_angles.sizes()[0];

#pragma omp parallel for
for(int i=0; i<batch_size; i++){

torch::Tensor single_sequence = sequences[i];
torch::Tensor single_atom_names = atom_names[i];
torch::Tensor single_res_names = res_names[i];
torch::Tensor single_angles = input_angles[i];
torch::Tensor single_coords = output_coords[i];

std::string seq = StringUtil::tensor2String(single_sequence);

int length = single_angles.sizes()[1];
int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal);

if( single_coords.sizes()[0]<3*num_atoms){
ERROR("incorrect coordinates tensor length");
}

if( length<seq.length() || single_angles.sizes()[0]<8 ){
ERROR("incorrect angles tensor length");
}

if( single_res_names.sizes()[0]<seq.length() ){
ERROR("incorrect res names tensor length");
}

if( single_atom_names.sizes()[0]<seq.length() ){
ERROR("incorrect atom names tensor length");
}
torch::Tensor dummy_grad = torch::zeros_like(single_angles);
AT_DISPATCH_FLOATING_TYPES(single_angles.type(), "cConformation", ([&] {
cConformation<scalar_t> conf( seq, single_angles.data<scalar_t>(), dummy_grad.data<scalar_t>(), length, single_coords.data<scalar_t>());
for(int j=0; j<conf.groups.size(); j++){
for(int k=0; k<conf.groups[j]->atomNames.size(); k++){
int idx = conf.groups[j]->atomIndexes[k];
torch::Tensor single_atom_name = single_atom_names[idx];
torch::Tensor single_res_name = single_res_names[idx];
StringUtil::string2Tensor(ProtUtil::convertRes1to3(conf.groups[j]->residueName), single_res_name);
StringUtil::string2Tensor(conf.groups[j]->atomNames[k], single_atom_name);

if(polymer_type == 0){

#pragma omp parallel for

for(int i=0; i<batch_size; i++){

torch::Tensor single_sequence = sequences[i];
torch::Tensor single_atom_names = atom_names[i];
torch::Tensor single_res_names = res_names[i];
torch::Tensor single_res_nums = res_nums[i];
torch::Tensor single_angles = input_angles[i];
torch::Tensor single_coords = output_coords[i];

std::string seq = StringUtil::tensor2String(single_sequence);

int length = single_angles.sizes()[1];

int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal);

if( single_coords.sizes()[0]<3*num_atoms){

ERROR("incorrect coordinates tensor length");
}

if( length<seq.length() || single_angles.sizes()[0]<8 ){
ERROR("incorrect angles tensor length");
}

if( single_res_names.sizes()[0]<seq.length() ){
ERROR("incorrect res names tensor length");
}

if( single_atom_names.sizes()[0]<seq.length() ){
ERROR("incorrect atom names tensor length");
}
torch::Tensor dummy_grad = torch::zeros_like(single_angles);
// Conformation and convertRes1to3
AT_DISPATCH_FLOATING_TYPES(single_angles.type(), "cConformation", ([&] {
cConformation<scalar_t> conf( seq, single_angles.data<scalar_t>(), dummy_grad.data<scalar_t>(), length, single_coords.data<scalar_t>(), polymer_type, chain_names);
for(int j=0; j<conf.groups.size(); j++){
for(int k=0; k<conf.groups[j]->atomNames.size(); k++){
int idx = conf.groups[j]->atomIndexes[k];
torch::Tensor single_atom_name = single_atom_names[idx];
torch::Tensor single_res_name = single_res_names[idx];
single_res_nums[idx] = (int)conf.groups[j]->residueIndex;
StringUtil::string2Tensor(ProtUtil::convertRes1to3(conf.groups[j]->residueName), single_res_name);
StringUtil::string2Tensor(conf.groups[j]->atomNames[k], single_atom_name);
}
}
}
}));
// cConformation<double> conf( seq, single_angles.data<double>(), dummy_grad.data<double>(),
// length, single_coords.data<double>());
//Output atom names and residue names

}));
// cConformation<double> conf( seq, single_angles.data<double>(), dummy_grad.data<double>(),
// length, single_coords.data<double>());
//Output atom names and residue names
}
}
if(polymer_type == 1 or polymer_type == 2){

#pragma omp parallel for

for(int i=0; i<batch_size; i++){

torch::Tensor single_sequence = sequences[i];
torch::Tensor single_atom_names = atom_names[i];
torch::Tensor single_res_names = res_names[i];
torch::Tensor single_res_nums = res_nums[i];
torch::Tensor single_angles = input_angles[i];
torch::Tensor single_coords = output_coords[i];

std::string seq = StringUtil::tensor2String(single_sequence);

int length = single_angles.sizes()[1];


int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal, polymer_type, chain_names);

if( single_coords.sizes()[0]<3*num_atoms){
ERROR("incorrect coordinates tensor length");
}

if( length<seq.length() || single_angles.sizes()[0]<10){
ERROR("incorrect angles tensor length");
}

if( single_res_names.sizes()[0]<seq.length() ){
ERROR("incorrect res names tensor length");
}

if( single_atom_names.sizes()[0]<seq.length() ){
ERROR("incorrect atom names tensor length");
}
torch::Tensor dummy_grad = torch::zeros_like(single_angles);
// Conformation and convertRes1to3

AT_DISPATCH_FLOATING_TYPES(single_angles.type(), "cConformation", ([&] {
cConformation<scalar_t> conf( seq, single_angles.data<scalar_t>(), dummy_grad.data<scalar_t>(), length, single_coords.data<scalar_t>(), polymer_type, chain_names);
for(int j=0; j<conf.groups.size(); j++){
for(int k=0; k<conf.groups[j]->atomNames.size(); k++){
int idx = conf.groups[j]->atomIndexes[k];
torch::Tensor single_atom_name = single_atom_names[idx];
torch::Tensor single_res_name = single_res_names[idx];
single_res_nums[idx] = (int)conf.groups[j]->residueIndex;
StringUtil::string2Tensor(ProtUtil::convertRes1to3(conf.groups[j]->residueName, polymer_type), single_res_name);
StringUtil::string2Tensor(conf.groups[j]->atomNames[k], single_atom_name);}
}
}));
}
}
}

void Angles2Coords_backward( torch::Tensor grad_atoms,
torch::Tensor grad_angles,
torch::Tensor sequences,
torch::Tensor input_angles
torch::Tensor input_angles,
int polymer_type,
torch::Tensor chain_names
){
bool add_terminal = false;
CHECK_CPU_INPUT_TYPE(sequences, torch::kByte);
Expand All @@ -98,13 +163,15 @@ void Angles2Coords_backward( torch::Tensor grad_atoms,
torch::Tensor single_grad_atoms = grad_atoms[i];

std::string seq = StringUtil::tensor2String(single_sequence);


// Get Num Atoms
uint length = single_angles.sizes()[1];
int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal);
int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal, polymer_type, chain_names);

// Conformation
torch::Tensor dummy_coords = torch::zeros({3*num_atoms}, torch::TensorOptions().dtype(grad_atoms.dtype()));
AT_DISPATCH_FLOATING_TYPES(single_angles.type(), "cConformation", ([&] {
cConformation<scalar_t> conf(seq, single_angles.data<scalar_t>(), single_grad_angles.data<scalar_t>(),length, dummy_coords.data<scalar_t>());
cConformation<scalar_t> conf(seq, single_angles.data<scalar_t>(), single_grad_angles.data<scalar_t>(),length, dummy_coords.data<scalar_t>(), polymer_type, chain_names);
conf.backward(conf.root, single_grad_atoms.data<scalar_t>());
}));
// cConformation<double> conf( seq, single_angles.data<double>(), single_grad_angles.data<double>(),
Expand All @@ -125,7 +192,8 @@ void Angles2Coords_save( const char* sequence,
}
std::string aa(sequence);
uint length = aa.length();
int num_atoms = ProtUtil::getNumAtoms(aa, add_terminal);
int polymer_type = 1; //"hard coded" need to change to arg
int num_atoms = ProtUtil::getNumAtoms(aa, add_terminal, polymer_type);
torch::Tensor dummy_grad = torch::zeros_like(input_angles);
torch::Tensor dummy_coords = torch::zeros({3*num_atoms}, torch::TensorOptions().dtype(input_angles.dtype()));
AT_DISPATCH_FLOATING_TYPES(input_angles.type(), "cConformation.save", ([&]{
Expand All @@ -136,9 +204,9 @@ void Angles2Coords_save( const char* sequence,

}

int getSeqNumAtoms( const char *sequence){
int getSeqNumAtoms( const char *sequence, int polymer_type, torch::Tensor chain_names){
bool add_terminal = false;
std::string seq(sequence);
int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal);
int num_atoms = ProtUtil::getNumAtoms(seq, add_terminal, polymer_type, chain_names);
return num_atoms;
}
11 changes: 8 additions & 3 deletions Layers/FullAtomModel/Angles2Coords/angles2coords_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@ void Angles2Coords_forward( at::Tensor sequences,
at::Tensor input_angles,
at::Tensor output_coords,
at::Tensor res_names,
at::Tensor atom_names
torch::Tensor res_nums,
at::Tensor atom_names,
int polymer_type,
torch::Tensor chain_names
);

void Angles2Coords_backward( at::Tensor grad_atoms,
at::Tensor grad_angles,
at::Tensor sequences,
at::Tensor input_angles
at::Tensor input_angles,
int polymer_type,
torch::Tensor chain_names
);
void Angles2Coords_save( const char* sequence,
at::Tensor input_angles,
const char* output_filename,
const char mode
);
int getSeqNumAtoms( const char *sequence);
int getSeqNumAtoms( const char *sequence, int polymer_type = 0, torch::Tensor chain_names = {});
Loading