-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclustering.py
More file actions
32 lines (26 loc) · 977 Bytes
/
Copy pathclustering.py
File metadata and controls
32 lines (26 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from subprocess import call
import os
import sys
import logging
class Cluster:
"""FASTA file clusterization"""
def __init__(self,
filename_gen,
identity,
threads):
"""Init cluster submodel"""
self.filename_gen = filename_gen
self.identity = identity
self.threads = threads
def do_cluster(self, fasta):
"""Cluster input fasta file"""
logging.info("Clustering with vsearch")
clustered_filename = self.filename_gen.compose_filename('clustered.fasta',True)
if call(f"""vsearch --cluster_fast {fasta} --threads {self.threads} \
--id {self.identity} --centroids {clustered_filename}""", shell=True)!=0:
logging.error("Clustering with vsearch failed")
sys.exit()
if not os.path.isfile(clustered_filename):
logging.error("Clustered file does not exist")
sys.exit()
return clustered_filename