Skip to content

Commit

Permalink
Adding dedicated download mode for database
Browse files Browse the repository at this point in the history
  • Loading branch information
tjakobi committed Apr 22, 2024
1 parent f3858ec commit bb954a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion circhemy/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,9 @@ def main():
# close db connection
util.db_connection.close()

elif args.command == "download":
util.setup_database(util, util.database_location, from_cli=True)

else:
print("Unknown command:", args.command)
exit(-1)

7 changes: 6 additions & 1 deletion circhemy/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def database_stats(self):

return chart_dict, dbsize, chart2_dict

def setup_database(self, database):
def setup_database(self, database, from_cli=False):

# check if there is a .bz2 version of the database
# if yes, this is the first time circhemy runs
Expand Down Expand Up @@ -323,6 +323,9 @@ def setup_database(self, database):
"https://github.com/jakobilab/circhemy/issues/new")
exit(-1)

if os.path.isfile(database) and from_cli:
print("Database already downloaded.")

self.db_connection = sqlite3.connect(database)

# SQLite optimizations from
Expand All @@ -341,6 +344,8 @@ def setup_database(self, database):
# getting db cursor
self.db_cursor = self.db_connection.cursor()



@staticmethod
def process_sql_output(sql_output, seperator="\t", empty_char="NA"):

Expand Down

0 comments on commit bb954a3

Please sign in to comment.