Skip to content

Commit

Permalink
updates cleaned files and auto load print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
raphenya committed Oct 24, 2022
1 parent 8031848 commit 752b9d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
22 changes: 12 additions & 10 deletions app/auto_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ def main(args):
logger.info("card variants version: {}".format(card_variants_version))

# Create the directory
logger.info("Creating temp directory with prefix {}".format(os.path.join(os.getcwd(), "rgi_autoload_")))
directory = tempfile.mkdtemp(prefix=os.path.join(os.getcwd(), "rgi_autoload_"))
print("Directory '%s' created" % directory)
print("=================================== DOWNLOAD CARD CANONICAL DATA ===================================")
logger.info("Directory '%s' created" % directory)
# print("Directory '%s' created" % directory)
logger.info("=================================== DOWNLOAD CARD CANONICAL DATA ===================================")
# get latest card database
data=os.path.join(directory,"data")
card_data=os.path.join(directory,"card_data")
Expand All @@ -37,7 +39,7 @@ def main(args):
os.system("mkdir -p {card_data}".format(card_data=card_data))
os.system("tar xf {data} -C {card_data}".format(data=data,card_data=card_data))

print("=================================== DOWNLOAD CARD VARIANTS DATA ===================================")
logger.info("=================================== DOWNLOAD CARD VARIANTS DATA ===================================")
variants=os.path.join(directory,"variants")
card_variants=os.path.join(directory,"card_variants")
os.system("wget -O {variants} --no-check-certificate https://card.mcmaster.ca/download/6/prevalence-v{card_variants_version}.tar.bz2".format(
Expand All @@ -49,21 +51,21 @@ def main(args):
os.system("tar xf {variants} -C {card_variants}".format(variants=variants,card_variants=card_variants))
os.system("gunzip {card_variants}/*.gz".format(card_variants=card_variants))

print("=================================== CARD CANONICAL ANNOTATIONS ===================================")
logger.info("=================================== CARD CANONICAL ANNOTATIONS ===================================")
os.system("rgi card_annotation --input {card_data}/card.json".format(card_data=card_data))

print("=================================== CARD VARIANTS ANNOTATIONS ===================================")
logger.info("=================================== CARD VARIANTS ANNOTATIONS ===================================")
os.system("rgi wildcard_annotation --input_directory {card_variants} --version {card_variants_version} --card_json {card_data}/card.json".format(
card_variants=card_variants,
card_variants_version=card_variants_version,
card_data=card_data
)
)

print("=================================== CLEAN OLD DATABASES ===================================")
logger.info("=================================== CLEAN OLD DATABASES ===================================")
os.system("rgi clean {debug} {local_database}".format(local_database=local_database,debug=debug))

print("=================================== LOAD DATABASES ===================================")
logger.info("=================================== LOAD DATABASES ===================================")
os.system("rgi load \
--card_json {card_data}/card.json \
--card_annotation card_database_v{card_cannonical_version}.fasta \
Expand All @@ -85,11 +87,11 @@ def main(args):
)
)

print("=================================== CHECK LOADED DATABASES ===================================")
logger.info("=================================== CHECK LOADED DATABASES ===================================")
os.system("rgi database -v --all {local_database}".format(local_database=local_database))

if args.clean:
print("=================================== CLEAN UP ===================================")
logger.info("=================================== CLEAN UP ===================================")
os.system("rm {data}".format(data=data))
os.system("rm {variants}".format(variants=variants))
os.system("rm {card_data}/* ".format(card_data=card_data))
Expand All @@ -102,7 +104,7 @@ def main(args):
os.system("rm wildcard_database_v{card_variants_version}.fasta".format(card_variants_version=card_variants_version))
os.system("rm wildcard_database_v{card_variants_version}_all.fasta".format(card_variants_version=card_variants_version))

print("=================================== DONE ===================================")
logger.info("=================================== DONE ===================================")

def get_versions():
r = requests.get('https://card.mcmaster.ca/download')
Expand Down
4 changes: 2 additions & 2 deletions app/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def clean():
remove_directory(f)
if os.path.isfile(f) and os.path.splitext(os.path.basename(f))[1][1:].strip() in ["adraft","xml","fsa","draft","pyc","log"]:
os.remove(f)

if os.path.isdir(f) == False:
if os.path.isfile(f) == True and os.path.splitext(os.path.basename(f))[1][1:].strip() in ["py","md"]:
pass
Expand All @@ -22,7 +22,7 @@ def clean():
# clean data files
data_files = glob.glob(os.path.join(data_path,"*"))
for datafile in data_files:
if os.path.isfile(datafile) and os.path.basename(datafile) not in ["loaded_databases.json","card.json", ".gitignore","__init__.py"]:
if os.path.isfile(datafile) and os.path.basename(datafile) not in ["card.json", ".gitignore","__init__.py"]:
logger.info("Remove: {}".format(datafile))
os.remove(datafile)
logger.info("Cleaned directory: {}".format(data_path))
Expand Down
2 changes: 1 addition & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def determine_path():
LOCAL_DATABASE = os.path.join(os.getcwd(), "localDB")

APP_NAME="Resistance Gene Identifier"
SOFTWARE_VERSION = "6.0.0"
SOFTWARE_VERSION = "6.0.1"
SOFTWARE_SUMMARY = 'Use the Resistance Gene Identifier to predict resistome(s) from protein or nucleotide \
data based on homology and SNP models. Check https://card.mcmaster.ca/download for software and data updates. \
Receive email notification of monthly CARD updates via the CARD Mailing List \
Expand Down

0 comments on commit 752b9d4

Please sign in to comment.