File size: 3,589 Bytes
c5478f1
 
 
 
 
 
5919102
c5478f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b7f8dca
c5478f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cad0ce0
c5478f1
 
 
0e65f70
c5478f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5919102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import streamlit as st
import pandas as pd
import os
from pathlib import Path
from streamlit.errors import DuplicateWidgetID

main_content, right_sidebar = st.columns([5, 2])

@st.cache_data()
def toggle_state():
    return {"toggled": False}

if 'onthology' not in st.session_state:
    st.session_state['onthology'] = "No onthology selected"

def get_similar_meta_file(path):
    return path.parent / (str(path.stem) + "_meta.csv")

def projects():
    with main_content:
        projects = ["my_project", "make_it_meta"]
        st.markdown("# Project Creation and Naming")

        markdown = ""

        for project in projects:
            markdown += f"- {project}\n"

        st.markdown(markdown)

def datasets():
    with main_content:
        try:
            datasets = list((Path(".").resolve() / "samples").glob("*"))
            datasets_not_meta = [x for x in datasets if ("csv" in str(x) or "tsv" in str(x)) and "_meta" not in str(x)]
            datasets_meta = [x for x in datasets if ("csv" in str(x) or "tsv" in str(x)) and "_meta" in str(x)]

            st.markdown("# Data selection and Uploading")
            selected_option = st.selectbox("Select a dataset", set([x.stem for x in datasets_not_meta if get_similar_meta_file(x) in datasets_meta]))      
            
            selected_mode = st.selectbox("Select mode", ["Causual", "Makeitmeta"])
            

            for file in datasets:
                if selected_option == file.stem:  
                    sep = "," if "csv" in file.stem else "\t"      
                    if selected_mode == "Makeitmeta":
                        file = get_similar_meta_file(file)
                        sep = ","
                    
                    df = pd.read_csv(str(file), sep=sep)
                    st.experimental_data_editor(df, key="data_editor_" + str(selected_mode))

            st.markdown("### If you want to upload a dataset you can do it below:")

            uploaded_file = st.file_uploader("Upload a file", type=["csv", "tsv", "pk", "gz"])

            if uploaded_file is not None:
                # Do something with the uploaded file, e.g., display its name
                st.write(uploaded_file.name)
        except DuplicateWidgetID as e:
            pass
def labeling():
    with main_content:
        st.markdown("# Labeling selection and Uploading")
        if st.session_state.onthology:
            st.markdown(f"### Current onthologdy: {st.session_state.onthology}")
    with right_sidebar:
        query = st.text_input('Search bar', '')
        if query == "":
            st.write("Search results")
        else:
            st.write(f"Printing results for query: {query}")


def ontologies():
    with main_content:
        onthologies = ["caDSR", "UMLS"]
        st.markdown("# Ontology Selection")
        onthology = st.selectbox(
            'Select your onthology',
            tuple(onthologies)
        )
        st.session_state.onthology = onthology
        st.write('You selected:', onthology)


pages = {
    "Datasets": datasets,
    "Projects": projects,
    "Labeling": labeling,
    "Ontologies": ontologies
}


# st.sidebar.title("Navigation")
# selection1 = st.sidebar.button("Projects")
# if selection1:
#     projects()
# selection2 = st.sidebar.button("Datasets")
# if selection2:
#     datasets()
# selection3 = st.sidebar.button("Labeling")
# if selection3:
#     labeling()
# selection4 = st.sidebar.button("Ontologies")
# if selection4:
#     ontologies()

selected_page = st.sidebar.selectbox("Select a page", pages.keys())
pages[selected_page]()