Mercurial > repos > tduigou > save_to_db
annotate verification.py @ 5:f934215bdb78 draft default tip
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
| author | tduigou |
|---|---|
| date | Mon, 02 Jun 2025 10:29:28 +0000 |
| parents | 6854ac8c5d2b |
| children |
| rev | line source |
|---|---|
|
0
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
1 from sqlalchemy import create_engine, text |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
2 |
|
1
6854ac8c5d2b
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
0
diff
changeset
|
3 db_uri = "postgresql://postgres:RK17@localhost:5432/test_fragments_db" #adapt with your URI's DB |
|
0
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
4 engine = create_engine(db_uri) |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
5 |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
6 with engine.connect() as conn: |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
7 result = conn.execute(text(""" |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
8 SELECT fragment, sequence, annotation |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
9 FROM sample |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
10 ORDER BY fragment |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
11 """)) |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
12 |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
13 print("Full contents of fragments in DB:\n") |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
14 for row in result: |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
15 print(f" Fragment: {row.fragment}") |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
16 print(" Sequence:") |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
17 print(row.sequence) |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
18 print("\n Annotation:") |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
19 print(row.annotation) |
|
034686b5bc15
planemo upload for repository https://github.com/brsynth commit 6ae809b563b40bcdb6be2e74fe2a84ddad5484ae
tduigou
parents:
diff
changeset
|
20 print("-" * 80) |
