abuendia commited on
Commit
f097bca
1 Parent(s): 50d23cb

Add proscope updates

Browse files
Files changed (1) hide show
  1. app/main.py +11 -10
app/main.py CHANGED
@@ -14,7 +14,7 @@ import numpy as np
14
  from atac_rna_data_processing.config.load_config import load_config
15
  from atac_rna_data_processing.io.celltype import GETCellType
16
  from atac_rna_data_processing.io.nr_motif_v1 import NrMotifV1
17
- from proscope.af2 import AFPairseg
18
  from proscope.data import get_genename_to_uniprot, get_lddt, get_seq
19
  from proscope.protein import Protein
20
  from proscope.viewer import view_pdb_html
@@ -33,7 +33,7 @@ args.add_argument("-n", "--host", type=str, default="127.0.0.1")
33
  args = args.parse_args()
34
 
35
  GET_CONFIG = load_config(
36
- "./modules/atac_rna_data_processing/atac_rna_data_processing/config/GET"
37
  )
38
  GET_CONFIG.celltype.jacob = True
39
  GET_CONFIG.celltype.num_cls = 2
@@ -42,8 +42,8 @@ GET_CONFIG.celltype.embed = True
42
  plt.rcParams["figure.dpi"] = 100
43
 
44
  if args.s3_uri: # Use S3 path if exists
45
- s3 = s3fs.S3FileSystem(anon=True)
46
- GET_CONFIG.s3_file_sys = s3
47
  GET_CONFIG.celltype.data_dir = (
48
  f"{args.s3_uri}/pretrain_human_bingren_shendure_apr2023/fetal_adult/"
49
  )
@@ -61,10 +61,10 @@ if args.s3_uri: # Use S3 path if exists
61
  available_celltypes = sorted(
62
  [
63
  cell_type_id_to_name[f.split("/")[-1]]
64
- for f in s3.glob(GET_CONFIG.celltype.interpret_dir + "*")
65
  ]
66
  )
67
- gene_pairs = s3.glob(f"{args.s3_uri}/structures/causal/*")
68
  gene_pairs = [os.path.basename(pair) for pair in gene_pairs]
69
  motif = NrMotifV1.load_from_pickle(
70
  pkg_resources.resource_filename("atac_rna_data_processing", "data/NrMotifV1.pkl"),
@@ -106,10 +106,11 @@ def visualize_AF2(tf_pair, a):
106
  else:
107
  strcture_dir = f"{args.data}/structures/causal/{tf_pair}"
108
  fasta_dir = f"{args.data}/sequences/causal/{tf_pair}"
109
- if not os.path.exists(strcture_dir):
110
- gr.ErrorText("No such gene pair")
111
 
112
- a = AFPairseg(strcture_dir, fasta_dir)
 
 
 
113
  # segpair.choices = list(a.pairs_data.keys())
114
  fig1, ax1 = a.plot_plddt_gene1()
115
  fig2, ax2 = a.plot_plddt_gene2()
@@ -123,7 +124,7 @@ def visualize_AF2(tf_pair, a):
123
 
124
  def view_pdb(seg_pair, a):
125
  pdb_path = a.pairs_data[seg_pair].pdb
126
- return view_pdb_html(pdb_path), a, pdb_path
127
 
128
 
129
  def update_dropdown(x, label):
 
14
  from atac_rna_data_processing.config.load_config import load_config
15
  from atac_rna_data_processing.io.celltype import GETCellType
16
  from atac_rna_data_processing.io.nr_motif_v1 import NrMotifV1
17
+ from proscope.af2 import GETAFPairseg
18
  from proscope.data import get_genename_to_uniprot, get_lddt, get_seq
19
  from proscope.protein import Protein
20
  from proscope.viewer import view_pdb_html
 
33
  args = args.parse_args()
34
 
35
  GET_CONFIG = load_config(
36
+ "/app/modules/atac_rna_data_processing/atac_rna_data_processing/config/GET"
37
  )
38
  GET_CONFIG.celltype.jacob = True
39
  GET_CONFIG.celltype.num_cls = 2
 
42
  plt.rcParams["figure.dpi"] = 100
43
 
44
  if args.s3_uri: # Use S3 path if exists
45
+ s3_file_sys = s3fs.S3FileSystem(anon=True)
46
+ GET_CONFIG.s3_file_sys = s3_file_sys
47
  GET_CONFIG.celltype.data_dir = (
48
  f"{args.s3_uri}/pretrain_human_bingren_shendure_apr2023/fetal_adult/"
49
  )
 
61
  available_celltypes = sorted(
62
  [
63
  cell_type_id_to_name[f.split("/")[-1]]
64
+ for f in s3_file_sys.glob(GET_CONFIG.celltype.interpret_dir + "*")
65
  ]
66
  )
67
+ gene_pairs = s3_file_sys.glob(f"{args.s3_uri}/structures/causal/*")
68
  gene_pairs = [os.path.basename(pair) for pair in gene_pairs]
69
  motif = NrMotifV1.load_from_pickle(
70
  pkg_resources.resource_filename("atac_rna_data_processing", "data/NrMotifV1.pkl"),
 
106
  else:
107
  strcture_dir = f"{args.data}/structures/causal/{tf_pair}"
108
  fasta_dir = f"{args.data}/sequences/causal/{tf_pair}"
 
 
109
 
110
+ if not os.path.exists(strcture_dir):
111
+ gr.ErrorText("No such gene pair")
112
+
113
+ a = GETAFPairseg(strcture_dir, fasta_dir, GET_CONFIG)
114
  # segpair.choices = list(a.pairs_data.keys())
115
  fig1, ax1 = a.plot_plddt_gene1()
116
  fig2, ax2 = a.plot_plddt_gene2()
 
124
 
125
  def view_pdb(seg_pair, a):
126
  pdb_path = a.pairs_data[seg_pair].pdb
127
+ return view_pdb_html(pdb_path, s3_file_sys=s3_file_sys), a, pdb_path
128
 
129
 
130
  def update_dropdown(x, label):