Skip to content

Commit

Permalink
Add logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelet committed Jul 11, 2024
1 parent a84185d commit 6a929e5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tools/rna_tools/rnaformer/infer_rnaformer.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="infer_rnaformer" name="@EXECUTABLE" version="@TOOL_VERSION@" profile="22.05">
<tool id="infer_rnaformer" name="@EXECUTABLE@" version="@TOOL_VERSION@" profile="22.05">
<description>Predict the secondary structure of an RNA with RNAformer</description>
<macros>
<token name="@EXECUTABLE@">RNAformer</token>
Expand All @@ -7,7 +7,7 @@
<expand macro="requirements">
<requirement type="package" version="1.83">biopython</requirement>
</expand>
<command detect_errors="exit_code"><![CDATA[python '$script_file' > '$output'
<command detect_errors="exit_code"><![CDATA[python '$script_file' > '$output'
]]></command>
<configfiles>
<configfile name="script_file"><![CDATA[import RNAformer
Expand All @@ -24,19 +24,27 @@ from RNAformer.utils.configuration import Config
from Bio import SeqIO
import logging
import sys
print("Start tool", file=sys.stderr)
config_file_path = '$__tool_directory__/RNAformer_32M_config_intra_family_finetuned.yml'
model_file_path = '$__tool_directory__/RNAformer_32M_state_dict_intra_family_finetuned.pth'
if not os.path.exists(model_file_path):
print("No model, try downloading", file=sys.stderr)
download_url = "https://ml.informatik.uni-freiburg.de/research-artifacts/RNAformer/models/RNAformer_32M_state_dict_intra_family_finetuned.pth"
logging.info(f"Model file {model_file_path} not found. Downloading from {download_url}...")
urllib.request.urlretrieve(download_url, model_file_path)
logging.info(f"Downloaded model file to {model_file_path}.")
if not os.path.exists(config_file_path):
p rint("No config, try downloading", file=sys.stderr)
download_url = "https://ml.informatik.uni-freiburg.de/research-artifacts/RNAformer/models/RNAformer_32M_config_intra_family_finetuned.yml"
logging.info(f"Model file {config_file_path} not found. Downloading from {download_url}...")
urllib.request.urlretrieve(download_url, config_file_path)
logging.info(f"Downloaded model file to {config_file_path}.")
print("Load model and config", file=sys.stderr)
config = Config(config_file=config_file_path)
config.RNAformer.cycling = 6
model = RiboFormer(config.RNAformer)
Expand Down
1 change: 1 addition & 0 deletions tools/rna_tools/rnaformer/macros.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<macros>
<token name="@EXECUTABLE@">RNAformer</token>
<token name="@TOOL_VERSION@">1.0.0</token>
<token name="@profile@">22.05</token>
<xml name="requirements">
Expand Down

0 comments on commit 6a929e5

Please sign in to comment.