fuxialexander commited on
Commit
8bdf52a
0 Parent(s):
Files changed (6) hide show
  1. .gitignore +1 -0
  2. .gitmodules +3 -0
  3. Dockerfile +44 -0
  4. app/__init__.py +0 -0
  5. app/main.py +80 -0
  6. modules/proscope +1 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ data
.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "modules/proscope"]
2
+ path = modules/proscope
3
+ url = [email protected]:fuxialexander/proscope.git
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official miniconda3 as a parent image
2
+ FROM mambaorg/micromamba
3
+
4
+ # Set the working directory in the container to /app
5
+ WORKDIR /app
6
+
7
+
8
+ # Create a new environment using mamba with specified packages
9
+ RUN micromamba install -n base -c conda-forge -c bioconda -y python=3.10 git pip biopython nglview tqdm matplotlib pandas xmlschema seaborn numpy py3Dmol
10
+ ARG MAMBA_DOCKERFILE_ACTIVATE=1
11
+ # Activate the environment and install additional packages via pip
12
+ RUN pip3 install gradio
13
+
14
+ USER root
15
+
16
+ RUN apt-get update && apt-get install -y --no-install-recommends \
17
+ git \
18
+ ssh \
19
+ && apt-get clean \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ USER $MAMBA_USER
23
+
24
+ # copy modules from local to container
25
+ COPY --chown=$MAMBA_USER:$MAMBA_USER modules /app/modules
26
+
27
+ # copy modules from local to container
28
+ COPY --chown=$MAMBA_USER:$MAMBA_USER app /app/app
29
+
30
+ # copy modules from local to container
31
+ # COPY --chown=$MAMBA_USER:$MAMBA_USER data /app/data
32
+
33
+ # Clone a specific git repository and install it as an editable package
34
+ RUN cd modules/proscope && \
35
+ pip3 install .
36
+
37
+ WORKDIR /app
38
+
39
+ # Make port 80 available to the world outside this container
40
+ EXPOSE 7681
41
+ # Set the working directory where your app resides
42
+
43
+ # Command to run the Gradio app automatically
44
+ CMD ["python", "app/main.py", "-p", "7681", "-s", "-d", "/data"]
app/__init__.py ADDED
File without changes
app/main.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import glob
2
+ import os
3
+
4
+ import argparse
5
+ import gradio as gr
6
+ import matplotlib.pyplot as plt
7
+ from proscope.data import get_seq, get_genename_to_uniprot, get_lddt
8
+ seq = get_seq()
9
+ genename_to_uniprot = get_genename_to_uniprot()
10
+ lddt = get_lddt()
11
+ from proscope.af2 import AFPairseg
12
+ from proscope.protein import Protein
13
+ from proscope.viewer import view_pdb_html
14
+
15
+
16
+ args = argparse.ArgumentParser()
17
+ args.add_argument("-p", "--port", type=int, default=7860, help="Port number")
18
+ args.add_argument("-s", "--share", action="store_true", help="Share on network")
19
+ args.add_argument("-d", "--data", type=str, default="/data", help="Data directory")
20
+ args = args.parse_args()
21
+ gene_pairs = glob.glob(f"{args.data}/structures/causal/*")
22
+ gene_pairs = [os.path.basename(pair) for pair in gene_pairs]
23
+
24
+ # set plot ppi to 100
25
+ plt.rcParams['figure.dpi'] = 100
26
+
27
+ def visualize_AF2(tf_pair, a):
28
+ strcture_dir = f"{args.data}/structures/causal/{tf_pair}"
29
+ fasta_dir = f"{args.data}/sequences/causal/{tf_pair}"
30
+ if not os.path.exists(strcture_dir):
31
+ gr.ErrorText("No such gene pair")
32
+
33
+ a = AFPairseg(strcture_dir, fasta_dir)
34
+ segpair.choices = list(a.pairs_data.keys())
35
+ fig1, ax1 = a.plot_plddt_gene1()
36
+ fig2, ax2 = a.plot_plddt_gene2()
37
+ fig3, ax3 = a.protein1.plot_plddt()
38
+ fig4, ax4 = a.protein2.plot_plddt()
39
+ fig5, ax5 = a.plot_score_heatmap()
40
+ plt.tight_layout()
41
+ new_dropdown = update_dropdown(list(a.pairs_data.keys()), 'Segment pair')
42
+ return fig1, fig2, fig3, fig4, fig5, new_dropdown, a
43
+
44
+ def view_pdb(seg_pair, a):
45
+ pdb_path = a.pairs_data[seg_pair].pdb
46
+ return view_pdb_html(pdb_path), a, pdb_path
47
+
48
+
49
+ def update_dropdown(x, label):
50
+ return gr.Dropdown.update(choices=x, label=label)
51
+
52
+
53
+ # main
54
+ if __name__ == '__main__':
55
+ with gr.Blocks(theme='sudeepshouche/minimalist') as demo:
56
+
57
+ seg_pairs = gr.State([''])
58
+ af = gr.State(None)
59
+ with gr.Row() as row:
60
+ with gr.Column():
61
+ tf_pairs = gr.Dropdown(label='TF pair', choices=gene_pairs)
62
+ tf_pairs_btn = gr.Button(value='Load & Plot')
63
+ interact_plddt1 = gr.Plot(label='Interact pLDDT 1')
64
+ interact_plddt2 = gr.Plot(label='Interact pLDDT 2')
65
+ protein1_plddt = gr.Plot(label='Protein 1 pLDDT')
66
+ protein2_plddt = gr.Plot(label='Protein 2 pLDDT')
67
+
68
+ heatmap = gr.Plot(label='Heatmap')
69
+
70
+ with gr.Column():
71
+ segpair = gr.Dropdown(label='Seg pair', choices=seg_pairs.value)
72
+ segpair_btn = gr.Button(value='Get PDB')
73
+ pdb_html = gr.HTML(label="PDB HTML")
74
+ pdb_file = gr.File(label='Download PDB')
75
+
76
+ tf_pairs_btn.click(visualize_AF2, inputs = [tf_pairs, af], outputs = [ interact_plddt1, interact_plddt2, protein1_plddt, protein2_plddt, heatmap, segpair, af])
77
+ segpair_btn.click(view_pdb, inputs=[segpair, af], outputs=[pdb_html, af, pdb_file])
78
+
79
+ demo.launch(share=args.share, server_port=args.port)
80
+
modules/proscope ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 3dd461a01e95eb9bb5a2b3e41f0dbe24fb9f3c76