Skip to content

Commit

Permalink
github actions pytest CI feature added
Browse files Browse the repository at this point in the history
  • Loading branch information
kbessonov1984 committed Jul 22, 2024
1 parent 86e1542 commit 33eac5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions ectyper/genomeFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_files_as_list(file_or_directory):
if os.path.exists(os.path.abspath(filename)):
files_list.append(os.path.abspath(filename))
else:
LOG.info("Checking file " + file_or_directory)
LOG.info("Checking existence of file " + file_or_directory)
input_abs_file_path = os.path.abspath(file_or_directory)
if os.path.exists(input_abs_file_path):
files_list.append(os.path.abspath(input_abs_file_path))
Expand Down Expand Up @@ -106,15 +106,13 @@ def get_genome_names_from_files(files_dict, temp_dir, args):
:param args: Commandline arguments
:return: Dictionary of files with the fasta headers modified for each filename {sampleid: {species:"","filepath":"","modheaderfile":"","error":""}}
"""

files=[]
for sample in files_dict.keys():
files.append(files_dict[sample]["filepath"])

LOG.debug("Updating fasta headers ....")
LOG.info("Updating fasta headers ....")
partial_ghw = partial(genome_header_wrapper, temp_dir=temp_dir)



with Pool(processes=args.cores) as pool:
(results)= pool.map(partial_ghw, files)

Expand Down Expand Up @@ -146,10 +144,14 @@ def genome_header_wrapper(file, temp_dir):

with open(new_file, "w") as outfile:
with open(file) as infile:
for record in SeqIO.parse(infile, "fasta"):
outfile.write(
">lcl|" + n_name + "|" + record.description.replace('|','_') + "\n") #the | symbol used to find contig names in FASTA headers so should be avoided
outfile.write(str(record.seq) + "\n")
try:
for record in SeqIO.parse(infile, "fasta"):
outfile.write(
">lcl|" + n_name + "|" + record.description.replace('|','_') + "\n") #the | symbol used to find contig names in FASTA headers so should be avoided
outfile.write(str(record.seq) + "\n")
except:
LOG.warning(f"File {infile.name} is not a valid FASTA file and all further processing steps will be skipped ...")
pass

return {"oldfile":file,"newfile":new_file, "samplename":n_name}

Expand Down
4 changes: 2 additions & 2 deletions test/test_O_serotyping.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_closeOalles_O42_O28(caplog):
ectyper.run_program()
with open(os.path.join(tmpdir,"output.tsv")) as outfp:
secondrow = outfp.readlines()[1]
assert re.match(r".+Escherichia coli.+O42\/O28\tH25\tO42\/O28:H25", secondrow)
assert re.match(r".+Escherichia coli.+O28\/O42\tH25\tO28\/O42:H25", secondrow)


def test_Shigella_typing(caplog):
Expand Down Expand Up @@ -179,7 +179,7 @@ def test_Ecoli_O17H18(caplog):
with open(os.path.join(tmpdir,"output.tsv")) as outfp:
rows = outfp.readlines()
secondrow=rows[1:][0] #check only second row
assert "Escherichia coli\tO77/O17/O44/O106\tH18\tO77/O17/O44/O106:H18\tWARNING MIXED O-TYPE" in secondrow
assert "Escherichia coli\tO17/O77/O44/O106\tH18\tO17/O77/O44/O106:H18\tWARNING MIXED O-TYPE" in secondrow

def test_download_refseq_mash(caplog, tmpdir):
caplog.set_level(logging.DEBUG)
Expand Down

0 comments on commit 33eac5d

Please sign in to comment.