Upload 8 files
Browse files- conversion.py +4 -1
- graphs.py +35 -28
- modeling_prot2text.py +14 -8
- pdb2graph.py +19 -12
- utils.py +5 -2
conversion.py
CHANGED
@@ -14,7 +14,10 @@ import networkx as nx
|
|
14 |
import numpy as np
|
15 |
import torch
|
16 |
|
17 |
-
|
|
|
|
|
|
|
18 |
|
19 |
try:
|
20 |
import torch_geometric
|
|
|
14 |
import numpy as np
|
15 |
import torch
|
16 |
|
17 |
+
try:
|
18 |
+
from graphein.utils.dependencies import import_message
|
19 |
+
except ImportError:
|
20 |
+
raise Exception('You need to install graphein from source in addition to DSSP to use this model please refer to https://github.com/a-r-j/graphein and https://ssbio.readthedocs.io/en/latest/instructions/dssp.html')
|
21 |
|
22 |
try:
|
23 |
import torch_geometric
|
graphs.py
CHANGED
@@ -15,37 +15,44 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Union
|
|
15 |
import networkx as nx
|
16 |
import numpy as np
|
17 |
import pandas as pd
|
18 |
-
|
19 |
-
|
20 |
-
from biopandas.
|
|
|
|
|
|
|
|
|
21 |
from rich.progress import Progress
|
22 |
from tqdm.contrib.concurrent import process_map
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
from graphein.protein.
|
35 |
-
from graphein.protein.
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
from graphein.
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
49 |
|
50 |
from .utils_convert import biopandas_mmcif2pdb
|
51 |
|
|
|
15 |
import networkx as nx
|
16 |
import numpy as np
|
17 |
import pandas as pd
|
18 |
+
|
19 |
+
try:
|
20 |
+
from biopandas.pdb import PandasPdb
|
21 |
+
from biopandas.mmcif import PandasMmcif
|
22 |
+
except ImportError:
|
23 |
+
raise Exception('You need to install BioPandas and its dependecies to use this model.')
|
24 |
+
|
25 |
from rich.progress import Progress
|
26 |
from tqdm.contrib.concurrent import process_map
|
27 |
|
28 |
+
try:
|
29 |
+
from graphein.protein.config import (
|
30 |
+
DSSPConfig,
|
31 |
+
GetContactsConfig,
|
32 |
+
ProteinGraphConfig,
|
33 |
+
)
|
34 |
+
from graphein.protein.edges.distance import (
|
35 |
+
add_distance_to_edges,
|
36 |
+
compute_distmat,
|
37 |
+
)
|
38 |
+
from graphein.protein.resi_atoms import BACKBONE_ATOMS, RESI_THREE_TO_1
|
39 |
+
from graphein.protein.subgraphs import extract_subgraph_from_chains
|
40 |
+
from graphein.protein.utils import (
|
41 |
+
ProteinGraphConfigurationError,
|
42 |
+
compute_rgroup_dataframe,
|
43 |
+
filter_dataframe,
|
44 |
+
get_protein_name_from_filename,
|
45 |
+
three_to_one_with_mods,
|
46 |
+
)
|
47 |
+
from graphein.rna.constants import RNA_ATOMS
|
48 |
+
from graphein.utils.utils import (
|
49 |
+
annotate_edge_metadata,
|
50 |
+
annotate_graph_metadata,
|
51 |
+
annotate_node_metadata,
|
52 |
+
compute_edges,
|
53 |
+
)
|
54 |
+
except ImportError:
|
55 |
+
raise Exception('You need to install graphein from source in addition to DSSP to use this model please refer to https://github.com/a-r-j/graphein and https://ssbio.readthedocs.io/en/latest/instructions/dssp.html')
|
56 |
|
57 |
from .utils_convert import biopandas_mmcif2pdb
|
58 |
|
modeling_prot2text.py
CHANGED
@@ -17,15 +17,21 @@ from .pdb2graph import PDB2Graph, download_alphafold_structure
|
|
17 |
from .graphs import *
|
18 |
from .utils_dataset import *
|
19 |
|
20 |
-
|
21 |
-
from graphein.protein.
|
22 |
-
from graphein.protein.features.nodes.
|
23 |
-
from graphein.protein.
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
|
|
|
17 |
from .graphs import *
|
18 |
from .utils_dataset import *
|
19 |
|
20 |
+
try:
|
21 |
+
from graphein.protein.config import ProteinGraphConfig, DSSPConfig
|
22 |
+
from graphein.protein.features.nodes.amino_acid import amino_acid_one_hot, meiler_embedding, expasy_protein_scale, hydrogen_bond_acceptor, hydrogen_bond_donor
|
23 |
+
from graphein.protein.features.nodes.dssp import phi, psi, asa, rsa, secondary_structure
|
24 |
+
from graphein.protein.edges.distance import (add_peptide_bonds,
|
25 |
+
add_hydrogen_bond_interactions,
|
26 |
+
add_distance_threshold,
|
27 |
+
)
|
28 |
+
except ImportError:
|
29 |
+
raise Exception('You need to install graphein from source in addition to DSSP to use this model please refer to https://github.com/a-r-j/graphein and https://ssbio.readthedocs.io/en/latest/instructions/dssp.html')
|
30 |
|
31 |
+
try:
|
32 |
+
from torch_geometric.nn import RGCNConv, global_mean_pool
|
33 |
+
except ImportError:
|
34 |
+
raise Exception('You need to install torch geometric and its dependecies to use this model please refer to https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html')
|
35 |
|
36 |
|
37 |
|
pdb2graph.py
CHANGED
@@ -3,23 +3,30 @@ import os
|
|
3 |
from tqdm import tqdm
|
4 |
from sklearn.preprocessing import MultiLabelBinarizer
|
5 |
|
6 |
-
|
|
|
|
|
|
|
7 |
import torch
|
8 |
|
9 |
import numpy as np
|
10 |
|
11 |
from .conversion import convert_nx_to_pyg_data
|
12 |
-
|
13 |
-
|
14 |
-
from graphein.protein.
|
15 |
-
from graphein.protein.
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
|
24 |
from functools import partial
|
25 |
from .graphs import *
|
|
|
3 |
from tqdm import tqdm
|
4 |
from sklearn.preprocessing import MultiLabelBinarizer
|
5 |
|
6 |
+
try:
|
7 |
+
from torch_geometric.data import Data
|
8 |
+
except ImportError:
|
9 |
+
raise Exception('You need to install torch geometric and its dependecies to use this model please refer to https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html')
|
10 |
import torch
|
11 |
|
12 |
import numpy as np
|
13 |
|
14 |
from .conversion import convert_nx_to_pyg_data
|
15 |
+
|
16 |
+
try:
|
17 |
+
from graphein.protein.config import ProteinGraphConfig, DSSPConfig
|
18 |
+
from graphein.protein.features.nodes.amino_acid import amino_acid_one_hot, meiler_embedding, expasy_protein_scale, hydrogen_bond_acceptor, hydrogen_bond_donor
|
19 |
+
from graphein.protein.features.nodes.dssp import phi, psi, asa, rsa, secondary_structure
|
20 |
+
from graphein.protein.edges.distance import (add_peptide_bonds,
|
21 |
+
add_hydrogen_bond_interactions,
|
22 |
+
add_disulfide_interactions,
|
23 |
+
add_ionic_interactions,
|
24 |
+
add_delaunay_triangulation,
|
25 |
+
add_distance_threshold,
|
26 |
+
add_sequence_distance_edges,
|
27 |
+
add_k_nn_edges)
|
28 |
+
except ImportError:
|
29 |
+
raise Exception('You need to install graphein from source in addition to DSSP to use this model please refer to https://github.com/a-r-j/graphein and https://ssbio.readthedocs.io/en/latest/instructions/dssp.html')
|
30 |
|
31 |
from functools import partial
|
32 |
from .graphs import *
|
utils.py
CHANGED
@@ -10,8 +10,11 @@ from transformers.generation.stopping_criteria import StoppingCriteriaList
|
|
10 |
from transformers.generation.utils import GreedySearchOutput, GreedySearchEncoderDecoderOutput, BeamSearchOutput, BeamSearchEncoderDecoderOutput
|
11 |
from transformers.generation.beam_search import BeamScorer
|
12 |
|
13 |
-
|
14 |
-
from torch_geometric.
|
|
|
|
|
|
|
15 |
|
16 |
class _GPT2LMHeadModel(GPT2LMHeadModel):
|
17 |
def _init_(self, config):
|
|
|
10 |
from transformers.generation.utils import GreedySearchOutput, GreedySearchEncoderDecoderOutput, BeamSearchOutput, BeamSearchEncoderDecoderOutput
|
11 |
from transformers.generation.beam_search import BeamScorer
|
12 |
|
13 |
+
try:
|
14 |
+
from torch_geometric.loader import DataLoader
|
15 |
+
from torch_geometric.data import Dataset
|
16 |
+
except ImportError:
|
17 |
+
raise Exception('You need to install torch geometric and its dependecies to use this model please refer to https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html')
|
18 |
|
19 |
class _GPT2LMHeadModel(GPT2LMHeadModel):
|
20 |
def _init_(self, config):
|