Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue too many open files #16

Merged
merged 4 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions taranis/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def create_matrix(self) -> pd.DataFrame:
stderr.print(f"{e}")
sys.exit(1)

# Close the file handles
mash_distance_result.stdout.close()
mash_distance_result.stderr.close()

out_data = out.decode("UTF-8").split("\n")
allele_names = [item.split("\t")[0] for item in out_data[1:-1]]
# create file in memory to increase speed
Expand Down
10 changes: 10 additions & 0 deletions taranis/reference_alleles.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,21 @@ def stats_graphics(stats_folder: str, cluster_alleles: dict) -> None:
)
heading = "Locus name,cluster number,average,center allele,number of sequences"
summary_file = os.path.join(out_folder, "evaluate_cluster", "cluster_summary.csv")
locus_clustering_file = os.path.join(
out_folder, "evaluate_cluster", "cluster_per_locus.csv"
)
with open(summary_file, "w") as fo:
fo.write(heading + "\n")
fo.write("\n".join(clusters_list) + "\n")

_ = stats_graphics(out_folder, cluster_data_graph)

with open(locus_clustering_file, "w") as fo:
fo.write("number of clusters, number of locus\n")
sorted_clusters = dict(sorted(cluster_data_graph.items()))
for key, value in sorted_clusters.items():
fo.write(str(key) + "," + str(value) + "\n")

if eval_cluster:
heading = "Locus name,cluster number,result,alleles not match in blast,alleles not found in cluster"
eval_file = os.path.join(
Expand Down
Loading