Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions samplesheetutils/binaries/create_samplesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def create_samplesheet():

samplesheet_path = args.output_file

for file_name in file_list:
with open(file_name, "r") as fp:
for i_file_name in file_list:
with open(i_file_name, "r") as fp:
fasta_data = read_fasta(fp, read_data=True, single_line=(not args.monomer))
sample_data.extend(fasta_data)
logger.debug(f"Added sample {file_name}, {fasta_data}")
logger.debug(f"Added sample {i_file_name}, {fasta_data}")

samplesheet_path = args.output_file
logger.debug(f"Sample data array length: {len(sample_data)}")
Expand All @@ -154,8 +154,8 @@ def create_samplesheet():
file_list = [os.path.join(args.dir, f) for f in os.listdir(args.dir) if os.path.isfile(os.path.join(args.dir, f)) and re.search(args.fasta_regex, f)]
sample_data = []

for file_name in file_list:
with open(file_name, "r") as file_fp:
for i_file_name in file_list:
with open(i_file_name, "r") as file_fp:
sample_data.extend(read_fasta(file_fp, read_data=True, single_line=False))

samplesheet_path = args.output_file
Expand All @@ -168,21 +168,21 @@ def create_samplesheet():
logger.debug(f"File list aginst regex: {file_list}")
sample_data = []

for file_name in file_list:
with open(file_name, "r") as fp:
for i_file_name in file_list:
with open(i_file_name, "r") as fp:
fasta_data = read_fasta(fp, read_data=True, single_line=False)
# Attempt to find MSA if the MSA directory flag is set
if args.msa_dir:
logger.debug(f"Searching for MSAs of {file_name}")
logger.debug(f"Searching for MSAs of {i_file_name}")
for fsi, i in zip(fasta_data, range(len(fasta_data))):
logger.debug("Checking for " + os.path.join(args.msa_dir, f"{fsi.name}.m3a"))
if os.path.isfile(os.path.join(args.msa_dir, f"{fsi.name}.m3a")):
fasta_data[i].msa = os.path.join(args.msa_dir, f"{fsi.name}.m3a")
logger.debug(f"Added pre-computed MSA for sample {fsi.name} of {file_name}: {fsi.msa}")
logger.debug(f"Added pre-computed MSA for sample {fsi.name} of {i_file_name}: {fsi.msa}")
else:
logger.debug(f"Corresponding MSA for sample {fsi.name} of {file_name} was not found, despite --msa-dir being set. Expected file name is {fsi.name}.m3a. Continuing with no MSA...")
logger.debug(f"Corresponding MSA for sample {fsi.name} of {i_file_name} was not found, despite --msa-dir being set. Expected file name is {fsi.name}.m3a. Continuing with no MSA...")
sample_data.extend(fasta_data)
logger.debug(f"Added sample {file_name}, {fasta_data}")
logger.debug(f"Added sample {i_file_name}, {fasta_data}")
logger.debug(f"Sample data {sample_data[-1].data}")

if args.output_file == "samplesheet.csv":
Expand Down