habdine commited on
Commit
8b4088d
1 Parent(s): 87dcc4e

Update code

Browse files
Files changed (5) hide show
  1. conversion.py +4 -1
  2. graphs.py +35 -28
  3. modeling_prot2text.py +14 -8
  4. pdb2graph.py +19 -12
  5. 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
- from graphein.utils.dependencies import import_message
 
 
 
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
- # from Bio.PDB.Polypeptide import three_to_one
19
- from biopandas.pdb import PandasPdb
20
- from biopandas.mmcif import PandasMmcif
 
 
 
 
21
  from rich.progress import Progress
22
  from tqdm.contrib.concurrent import process_map
23
 
24
- from graphein.protein.config import (
25
- DSSPConfig,
26
- GetContactsConfig,
27
- ProteinGraphConfig,
28
- )
29
- from graphein.protein.edges.distance import (
30
- add_distance_to_edges,
31
- compute_distmat,
32
- )
33
- from graphein.protein.resi_atoms import BACKBONE_ATOMS, RESI_THREE_TO_1
34
- from graphein.protein.subgraphs import extract_subgraph_from_chains
35
- from graphein.protein.utils import (
36
- ProteinGraphConfigurationError,
37
- compute_rgroup_dataframe,
38
- filter_dataframe,
39
- get_protein_name_from_filename,
40
- three_to_one_with_mods,
41
- )
42
- from graphein.rna.constants import RNA_ATOMS
43
- from graphein.utils.utils import (
44
- annotate_edge_metadata,
45
- annotate_graph_metadata,
46
- annotate_node_metadata,
47
- compute_edges,
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
- from graphein.protein.config import ProteinGraphConfig, DSSPConfig
21
- from graphein.protein.features.nodes.amino_acid import amino_acid_one_hot, meiler_embedding, expasy_protein_scale, hydrogen_bond_acceptor, hydrogen_bond_donor
22
- from graphein.protein.features.nodes.dssp import phi, psi, asa, rsa, secondary_structure
23
- from graphein.protein.edges.distance import (add_peptide_bonds,
24
- add_hydrogen_bond_interactions,
25
- add_distance_threshold,
26
- )
 
 
 
27
 
28
- from torch_geometric.nn import RGCNConv, global_mean_pool
 
 
 
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
- from torch_geometric.data import Data
 
 
 
7
  import torch
8
 
9
  import numpy as np
10
 
11
  from .conversion import convert_nx_to_pyg_data
12
- from graphein.protein.config import ProteinGraphConfig, DSSPConfig
13
- from graphein.protein.features.nodes.amino_acid import amino_acid_one_hot, meiler_embedding, expasy_protein_scale, hydrogen_bond_acceptor, hydrogen_bond_donor
14
- from graphein.protein.features.nodes.dssp import phi, psi, asa, rsa, secondary_structure
15
- from graphein.protein.edges.distance import (add_peptide_bonds,
16
- add_hydrogen_bond_interactions,
17
- add_disulfide_interactions,
18
- add_ionic_interactions,
19
- add_delaunay_triangulation,
20
- add_distance_threshold,
21
- add_sequence_distance_edges,
22
- add_k_nn_edges)
 
 
 
 
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
- from torch_geometric.loader import DataLoader
14
- from torch_geometric.data import Dataset
 
 
 
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):