Skip to content

Commit

Permalink
Updated all tests. Everything passes if ran on a computer with a CUDA…
Browse files Browse the repository at this point in the history
… enabled GPU.
  • Loading branch information
ryanemenecker committed Nov 4, 2024
1 parent 332d39f commit ee842bf
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 80 deletions.
9 changes: 8 additions & 1 deletion metapredict/backend/architectures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
import torch.nn as nn
import pytorch_lightning as L


'''
USED BY V1 and V2 disorder predictors!
USED BY V1 pLDDT predictor!
'''

class BRNN_MtM(nn.Module):
"""A PyTorch many-to-many bidirectional recurrent neural network
Expand Down Expand Up @@ -117,6 +120,10 @@ def forward(self, x):
# return decoded hidden state
return fc_out

'''
USED BY V3 disorder predictor!
USED BY V2 pLDDT predictor!
'''

class BRNN_MtM_lightning(L.LightningModule):
"""A PyTorch many-to-many bidirectional recurrent neural network
Expand Down
32 changes: 22 additions & 10 deletions metapredict/backend/network_parameters.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env python
"""
This holds all of the information on the networks we have in the /backend/networks folder.
This includes networks that we have published and those that were tested but not published.
This holds all of the information on the networks we have in /backend/networks for disorder
and /backend/ppLDDT/networks for pLDDT.
This includes networks that we have published and those that we tested but didn't end up using.
Explainations for networks can be found by calling the 'info' key in the dictionary for the
network. Why make this? Great question. The reason is that a lot of the names for the
networks in the networks folder are downright terrible (metaDisorder.pt is... bad). However,
network.
Why make this? Great question. The reason is that a lot of the names for the
networks in the /networks folder are downright terrible (metaDisorder.pt is... bad). However,
I don't want to change the names of those networks at this point because it would make them
hard to track down if anyone has kept track of the network names for whatever reason.
So - this is my Not So Clever Workaround™.
hard to track down. This is my Not So Clever Workaround™.
The other reason for this module is to hold the hyperparameters for networks we made before we
started using Pytorch-lightning. The importance of this is Pytorch-lightning holds more easily
accessible hyperparameter information that you don't need to dynamically load. However, we can't
use this functionalty for the old networks, so the workaround is to just have
things hardcoded here. This will also future proof us in case the Pytorch-lightning functionality
changes for whatever reason.
changes for whatever reason. It's also a nice place to look things up to see what parameters
we used for each network.
"""

# import the cutoff value parameters for each network from parameters.
Expand Down Expand Up @@ -81,7 +83,7 @@
'momentum': 0.9968434498981696,
'last_epoch': 100,
'disorder_threshold': METAPREDICT_V3_THRESHOLD,
'info': 'Similar to v2 metapredict as far as training data except real pLDDT scores pLDDT scores were based on AF2 V4 structures. Values were smoothed over a 25 residue sliding window post processing. Our current putative V3 network.',
'info': 'Similar to v2 metapredict as far as training data except we used real pLDDT scores based on AF2 V4 structures instead of predicted pLDDT. In addition, values were smoothed over a 25 residue sliding window before being used for training. Depending on some additional testing, this is likely to be our next released network.',
'type': 'disorder'
}

Expand All @@ -103,7 +105,7 @@
'epochs': 200,
'used_lightning': False,
'disorder_threshold': 'N/A',
'info': "pLDDT predictor network implemented in AlphaPredict. Original pLDDT predictor. Trained on same proteomes as metapredict V1 (legacy) pLDDT scores. Output scores from this predictor were used to make the metapredict V2 network.",
'info': "pLDDT predictor network implemented in AlphaPredict. Original pLDDT predictor. Trained on same proteomes as metapredict V1 (legacy) pLDDT scores. Output scores from this predictor combined with metapredict legacy disorder scores were used to make the metapredict V2 network.",
'type': 'pLDDT'
}

Expand All @@ -126,13 +128,23 @@
'used_lightning': True,
'last_epoch': 20,
'disorder_threshold': 'N/A',
'info': "Network made by Jeff. Trained on pLDDT scores from swissprot AF2 V4 PDBs. March 2024.",
'info': "Network made by Jeff. Trained on pLDDT scores from swissprot AF2 V4 PDBs. March 2024.",
'type': 'pLDDT'
}

#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
#=-=-=-=-=-= ADD USER-FACING STUFF HERE -=-=-=-=-=#
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
'''
Everything user-facing needs to be added here. For a version,
add 'V#' as a new key to the dictionary. That should then have
a value that is an additional key with two values:
'weights': the name of the file that holds the weights for the network
'parameters': the dictionary that holds the hyperparameters for the network.
the dictionary specified in 'parameters' needs to be defined with the same
key : value pairs as the dictionaries above.
'''


# dict to hold the networks that are user-facing.
metapredict_networks = {
Expand Down
20 changes: 10 additions & 10 deletions metapredict/backend/predictor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
#!/usr/bin/env python
"""
Functionality previously scattered across various different modules.
This holds all of the functionality for disorder prediction.
This holds all of the functionality for disorder and pLDDT prediction.
This includes batch and single sequence.
Device selection can be carried out from the predict function.
Output data type also from the predict function.
"""

# general imports
import os
from packaging import version as packaging_version
import time
import numpy as np
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm

# local imports
from metapredict.backend.data_structures import DisorderObject as _DisorderObject
from metapredict.backend import domain_definition as _domain_definition
Expand All @@ -16,15 +25,6 @@
from metapredict.backend import architectures
from metapredict.metapredict_exceptions import MetapredictError

# other imports
import os
from packaging import version as packaging_version
import time
import numpy as np
import torch
from torch.utils.data import DataLoader
from tqdm import tqdm

# ....................................................................................
#
def build_DisorderObject(s,
Expand Down
Binary file not shown.
Loading

0 comments on commit ee842bf

Please sign in to comment.