Skip to content

Commit

Permalink
Fixed linting mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
victor5lm committed Sep 30, 2024
1 parent 75ad889 commit 04c7ac6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
21 changes: 15 additions & 6 deletions bu_isciii/bioinfo_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,19 +652,26 @@ def email_creation(self):
).replace("\n", "<br />")
else:
if bu_isciii.utils.prompt_yn_question(
msg="Do you wish to provide a text file for email notes?", dflt=False
msg="Do you wish to provide a text file for email notes?",
dflt=False,
):
for i in range(3, -1, -1):
email_data["email_notes"] = bu_isciii.utils.prompt_path(
msg="Write the path to the file with RAW text as email notes"
)
if not os.path.isfile(os.path.expanduser(email_data["email_notes"])):
stderr.print(f"Provided file doesn't exist. Attempts left: {i}")
if not os.path.isfile(
os.path.expanduser(email_data["email_notes"])
):
stderr.print(
f"Provided file doesn't exist. Attempts left: {i}"
)
else:
stderr.print(f"File selected: {email_data["email_notes"]}")
stderr.print(f"File selected: {email_data['email_notes']}")
break
else:
stderr.print("No more attempts. Email notes will be given by prompt")
stderr.print(
"No more attempts. Email notes will be given by prompt"
)
email_data["email_notes"] = None
else:
email_data["email_notes"] = None
Expand All @@ -673,7 +680,9 @@ def email_creation(self):
with open(os.path.expanduser(email_data["email_notes"])) as f:
email_data["email_notes"] = f.read().replace("\n", "<br />")
else:
email_data["email_notes"] = bu_isciii.utils.ask_for_some_text(msg="Write email notes").replace("\n", "<br />")
email_data["email_notes"] = bu_isciii.utils.ask_for_some_text(
msg="Write email notes"
).replace("\n", "<br />")

email_data["user_data"] = self.resolution_info["service_user_id"]
email_data["service_id"] = self.service_name.split("_", 5)[0]
Expand Down
38 changes: 27 additions & 11 deletions bu_isciii/templates/viralrecon/RESULTS/excel_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def merge_lineage_tables(
csvs_in_folder=csvs_in_folder, merged_csv_name=merged_csv_name
)
else:
print(f"\033[93mNo pangolin folder could be found for {ref}, omitting\033[0m")
print(
f"\033[93mNo pangolin folder could be found for {ref}, omitting\033[0m"
)

if os.path.isdir(os.path.abspath(folder + "/nextclade")):
nextcl_dir = os.path.join(folder, "nextclade")
Expand All @@ -82,13 +84,15 @@ def merge_lineage_tables(
csvs_in_folder=csvs_in_folder, merged_csv_name=merged_csv_name
)
else:
print(f"\033[93mNo nextclade folder could be found for {ref}, omitting\033[0m\n")
print(
f"\033[93mNo nextclade folder could be found for {ref}, omitting\033[0m\n"
)

return


def excel_generator(csv_files: List[str]):
#print("Proceeding")
# print("Proceeding")
for file in csv_files:
if not os.path.exists(file):
print(f"\033[91mFile {file} does not exist, omitting...\033[0m")
Expand Down Expand Up @@ -126,7 +130,9 @@ def single_csv_to_excel(csv_file: str):
def main(args):
if args.single_csv:
# If single_csv is called, just convert target csv to excel and skip the rest
print("\033[92mSingle file convertion selected. Skipping main process...\033[0m")
print(
"\033[92mSingle file convertion selected. Skipping main process...\033[0m"
)
single_csv_to_excel(args.single_csv)
exit(0)

Expand All @@ -135,7 +141,9 @@ def main(args):
)
with open(args.reference_file, "r") as file:
references = [line.rstrip() for line in file]
print(f"\n\033[92mFound {len(references)} references: {str(references).strip('[]')}\033[0m")
print(
f"\n\033[92mFound {len(references)} references: {str(references).strip('[]')}\033[0m"
)

reference_folders = {ref: str("excel_files_" + ref) for ref in references}
samples_ref_files = {
Expand All @@ -160,10 +168,14 @@ def main(args):
concat_tables_and_write(
csvs_in_folder=variants_tables, merged_csv_name="variants_long_table.csv"
)
except FileNotFoundError as e:
except FileNotFoundError:
print("\033[93mWARNING!\033[0m")
print("\033[93mAt least one variants_long_table.csv file could not be found. Therefore, merged variants_long_table.csv will be incomplete.\033[0m")
print("\033[93mPlease, check the following report in order to know which links are broken and, therefore, which tables could not be found:\033[0m\n")
print(
"\033[93mAt least one variants_long_table.csv file could not be found. Therefore, merged variants_long_table.csv will be incomplete.\033[0m"
)
print(
"\033[93mPlease, check the following report in order to know which links are broken and, therefore, which tables could not be found:\033[0m\n"
)

# Create excel files for individual tables
valid_extensions = [".csv", ".tsv", ".tab"]
Expand All @@ -177,9 +189,13 @@ def main(args):
valid_csvs = [file for file in rest_of_csvs if file not in broken_links]

if broken_links:
print(f"\033[93mWARNING! {len(broken_links)} broken links found (for .csv, .tsv or .tab files). Please fix them.\033[0m")
for broken_link in broken_links:
print(f"\033[93mBroken link: {broken_link} (target: {os.readlink(broken_link)})\033[0m")
print(
f"\033[93mWARNING! {len(broken_links)} broken links found (for .csv, .tsv or .tab files). Please fix them.\033[0m"
)
for broken_link in broken_links:
print(
f"\033[93mBroken link: {broken_link} (target: {os.readlink(broken_link)})\033[0m"
)

excel_generator(valid_csvs)

Expand Down

0 comments on commit 04c7ac6

Please sign in to comment.