Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,19 +6,6 @@ import requests
|
|
| 6 |
HF_DB_URL = "https://huggingface.co/datasets/babilonczyk/swiss_prot/resolve/main/proteins.db"
|
| 7 |
LOCAL_DB_PATH = "proteins.db"
|
| 8 |
|
| 9 |
-
def print_schema():
|
| 10 |
-
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
| 11 |
-
tables = cursor.fetchall()
|
| 12 |
-
print("๐ Tables:", tables)
|
| 13 |
-
|
| 14 |
-
for (table_name,) in tables:
|
| 15 |
-
print(f"\n๐ Columns in table '{table_name}':")
|
| 16 |
-
cursor.execute(f"PRAGMA table_info({table_name});")
|
| 17 |
-
for col in cursor.fetchall():
|
| 18 |
-
print(col)
|
| 19 |
-
|
| 20 |
-
print_schema()
|
| 21 |
-
|
| 22 |
# Download the DB only if not already cached
|
| 23 |
def download_db(url: str, local_path: str):
|
| 24 |
if not os.path.exists(local_path):
|
|
@@ -40,6 +27,20 @@ download_db(HF_DB_URL, LOCAL_DB_PATH)
|
|
| 40 |
conn = get_connection(LOCAL_DB_PATH)
|
| 41 |
cursor = conn.cursor()
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
# Query function
|
| 44 |
def search_by_sequence(seq: str) -> str:
|
| 45 |
seq = seq.strip().upper()
|
|
|
|
| 6 |
HF_DB_URL = "https://huggingface.co/datasets/babilonczyk/swiss_prot/resolve/main/proteins.db"
|
| 7 |
LOCAL_DB_PATH = "proteins.db"
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Download the DB only if not already cached
|
| 10 |
def download_db(url: str, local_path: str):
|
| 11 |
if not os.path.exists(local_path):
|
|
|
|
| 27 |
conn = get_connection(LOCAL_DB_PATH)
|
| 28 |
cursor = conn.cursor()
|
| 29 |
|
| 30 |
+
|
| 31 |
+
def print_schema():
|
| 32 |
+
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
| 33 |
+
tables = cursor.fetchall()
|
| 34 |
+
print("๐ Tables:", tables)
|
| 35 |
+
|
| 36 |
+
for (table_name,) in tables:
|
| 37 |
+
print(f"\n๐ Columns in table '{table_name}':")
|
| 38 |
+
cursor.execute(f"PRAGMA table_info({table_name});")
|
| 39 |
+
for col in cursor.fetchall():
|
| 40 |
+
print(col)
|
| 41 |
+
|
| 42 |
+
print_schema()
|
| 43 |
+
|
| 44 |
# Query function
|
| 45 |
def search_by_sequence(seq: str) -> str:
|
| 46 |
seq = seq.strip().upper()
|