Skip to content

Commit

Permalink
improve --output-prefix behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
aozalevsky committed May 10, 2024
1 parent 0e176aa commit 74cb1af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions ihm_validation/ihm_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def createdirs(dirNames: dict):
logging.info(f"Directory {name} created ")


def write_html(mmcif_file: str, template_dict: dict, template_list: list, dirName: str):
def write_html(prefix: str, template_dict: dict, template_list: list, dirName: str):
for template_file in template_list:
template = templateEnv.get_template(template_file)
outputText = template.render(template_dict)
Expand All @@ -210,11 +210,11 @@ def write_html(mmcif_file: str, template_dict: dict, template_list: list, dirNam
fh.write(outputText)


def write_pdf(mmcif_file: str, template_dict: dict, template_file: str, dirName: str, dirName_Output: str):
def write_pdf(prefix: str, template_dict: dict, template_file: str, dirName: str, dirName_Output: str):
template = templateEnv.get_template(template_file)
outputText = template.render(template_dict)
temp_html = os.path.join(dirName, utility.get_output_file_temp_html(mmcif_file))
output_pdf = os.path.join(dirName_Output, utility.get_output_file_pdf(mmcif_file))
temp_html = os.path.join(dirName, utility.get_output_file_temp_html(prefix))
output_pdf = os.path.join(dirName_Output, utility.get_output_file_pdf(prefix))

with open(temp_html, "w") as fh:
fh.write(outputText)
Expand All @@ -224,11 +224,11 @@ def write_pdf(mmcif_file: str, template_dict: dict, template_file: str, dirName:

return output_pdf

def write_supplementary_table(mmcif_file: str, template_dict: dict, template_file: str, dirName: str, dirName_supp: str):
def write_supplementary_table(prefix: str, template_dict: dict, template_file: str, dirName: str, dirName_supp: str):
template = templateEnv.get_template(template_file)
outputText = template.render(template_dict)
temp_html = os.path.join(dirName, utility.get_supp_file_html(mmcif_file))
output_pdf = os.path.join(dirName_supp, utility.get_supp_file_pdf(mmcif_file))
temp_html = os.path.join(dirName, utility.get_supp_file_html(prefix))
output_pdf = os.path.join(dirName_supp, utility.get_supp_file_pdf(prefix))

with open(temp_html, "w") as fh:
fh.write(outputText)
Expand Down Expand Up @@ -317,7 +317,7 @@ def write_json(mmcif_file: str, template_dict: dict, dirName: str, dirName_Outpu
molprobity_dict, exv_data, sas_data, sas_fit, cx_fit, imageDirName=dirNames['images'])

logging.info("Write PDF")
output_pdf = write_pdf(args.f, template_dict, template_pdf,
output_pdf = write_pdf(output_prefix, template_dict, template_pdf,
dirNames['pdf'], dirNames['pdf'])
shutil.copy(output_pdf, str(output_path))

Expand All @@ -335,7 +335,7 @@ def write_json(mmcif_file: str, template_dict: dict, dirName: str, dirName_Outpu
clustering=None,
)
output_pdf = write_supplementary_table(
args.f, template_dict, template_file_supp, dirNames['pdf'], dirNames['pdf'])
output_prefix, template_dict, template_file_supp, dirNames['pdf'], dirNames['pdf'])
shutil.copy(output_pdf, str(output_path))

template_dict['supplementary_pdf'] = Path(output_pdf).name
Expand All @@ -346,7 +346,7 @@ def write_json(mmcif_file: str, template_dict: dict, dirName: str, dirName_Outpu
logging.info("Write HTML")
# set html mode
template_dict['html_mode'] = args.html_mode
write_html(args.f, template_dict, template_flask, dirNames['html'])
write_html(output_prefix, template_dict, template_flask, dirNames['html'])
if args.html_mode == 'local':
shutil.copytree(
args.html_resources,
Expand Down
22 changes: 11 additions & 11 deletions ihm_validation/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,46 +210,46 @@ def runInParallel_noargs(*fns):
p.join()


def get_output_file_html(mmcif_file: str) -> str:
def get_output_file_html(prefix: str) -> str:
'''
minor func
'''
return f'ValidationReport_{Path(mmcif_file).stem}.html'
return f'ValidationReport_{prefix}.html'


def get_supp_file_html(mmcif_file: str) -> str:
def get_supp_file_html(prefix: str) -> str:
'''
minor func
'''
return f'Supplementary_{Path(mmcif_file).stem}.html'
return f'Supplementary_{prefix}.html'


def get_output_file_temp_html(mmcif_file: str) -> str:
def get_output_file_temp_html(prefix: str) -> str:
'''
minor func
'''
return 'temp.html'


def get_output_file_pdf(mmcif_file: str) -> str:
def get_output_file_pdf(prefix: str) -> str:
'''
minor func
'''
return f'{Path(mmcif_file).stem}_full_validation.pdf'
return f'{prefix}_full_validation.pdf'


def get_output_file_json(mmcif_file: str) -> str:
def get_output_file_json(prefix: str) -> str:
'''
minor func
'''
return f'ValidationReport_{Path(mmcif_file).stem}.json'
return f'ValidationReport_{prefix}.json'


def get_supp_file_pdf(mmcif_file: str) -> str:
def get_supp_file_pdf(prefix: str) -> str:
'''
minor func
'''
return f'{Path(mmcif_file).stem}_summary_validation.pdf'
return f'{prefix}_summary_validation.pdf'


def get_subunits(sub_dict: dict) -> list:
Expand Down

0 comments on commit 74cb1af

Please sign in to comment.