Skip to content

Commit

Permalink
update 1.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroMTQ committed Feb 14, 2022
1 parent ccb91e9 commit e4b01a7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 42 deletions.
3 changes: 2 additions & 1 deletion config/MANTIS.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#default_ref_folder=
#####<custom_ref_folder> defines the folder where Mantis will look for MULTIPLE custom HMMs or DMND. Each HMM should be contained within a folder, such that the path will look something like this: /path/to/custom_ref_folder/custom1/custom1.hmm
#custom_ref_folder=
nog_ref=dmnd # dmnd or hmm
# dmnd or hmm
nog_ref=dmnd
#nog_ref_folder=
#pfam_ref_folder=
#kofam_ref_folder=
Expand Down
32 changes: 5 additions & 27 deletions mantis/Assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def __init__(self, verbose=True, redirect_verbose=None,no_taxonomy=False, mantis
self.hmm_chunk_size = hmm_chunk_size
self.read_config_file()

#self.requirements_met()
# I use manager instead of queue since I need to be able to add records to the end and start of the 'queue' (actually a list) which is not possible with the multiprocessing.Queue
# we need manager.list because a normal list cant communicate during multiprocessing
self.manager = Manager()
Expand Down Expand Up @@ -91,29 +90,6 @@ def __str__(self):

return res

def requirements_met(self):
for f in [self.is_conda_available(), self.is_hmmer_available()]:
if not f:
kill_switch(RequirementsNotMet)

def is_conda_available(self):
process = run_command('conda -V', get_output=True)
check = re.search('conda', str(process.stdout))
if not check:
print_cyan('Conda dependency not met!')
print_cyan('Install Conda on your system by following the instructions at: https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html')
return check

def is_hmmer_available(self):
check_command = ' conda list hmmer '
process = run_command(check_command, get_output=True)
check = re.search('hmmer', str(process.stdout))
if not check:
print_cyan('HMMER dependency not met!')
print_cyan('Install HMMER on your conda environment by doing the following:')
print_cyan('conda activate <conda_environment>')
print_cyan('conda install -c bioconda hmmer')
return check


def check_internet_connection(self):
Expand Down Expand Up @@ -222,10 +198,11 @@ def read_config_file(self):
self.config_file = self.mantis_config
else:
if not os.path.isdir(MANTIS_FOLDER):
print('Make sure you are calling the folder to run this package, like so:\n python mantis/ <command>\n ',
flush=True, file=self.redirect_verbose)
print('Make sure you are calling the folder to run this package, like so:\n python mantis/ <command>\n ',flush=True, file=self.redirect_verbose)
raise FileNotFoundError
self.config_file =f'{MANTIS_FOLDER}config{SPLITTER}MANTIS.cfg'
print(f'Using default MANTIS.cfg: {self.mantis_config}', flush=True, file=self.redirect_verbose)

try:
open(self.config_file, 'r')
except:
Expand Down Expand Up @@ -319,7 +296,6 @@ def check_reference_exists(self, database, taxon_id=None):
return True
elif database == 'taxonomy':
taxonomy_db=self.mantis_paths['resources'] + 'Taxonomy.db'
gtdb_resources = add_slash(self.mantis_paths['resources'] + 'GTDB')
if file_exists(taxonomy_db):
return True
elif database == 'NOGSQL':
Expand Down Expand Up @@ -511,6 +487,7 @@ def check_sql_databases(self,ref_dbs):
red('------------------------------------------', flush=True, file=self.redirect_verbose)
red('-------------SQL CHECK FAILED-------------', flush=True, file=self.redirect_verbose)
red('------------------------------------------', flush=True, file=self.redirect_verbose)
raise SQLCheckNotPassed


def check_installation(self, verbose=True,check_sql=False):
Expand Down Expand Up @@ -589,6 +566,7 @@ def check_installation(self, verbose=True,check_sql=False):
yellow('------------------------------------------', flush=True, file=self.redirect_verbose)
else:
print_cyan('Installation check failed', flush=True, file=self.redirect_verbose)
raise InstallationCheckNotPassed
if check_sql: self.check_sql_databases(ref_dbs)


Expand Down
2 changes: 1 addition & 1 deletion mantis/Database_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def compile_NOG_DMND(self):
eggnog_proteins_path = f'{folder_path}eggnog_seqs.faa'
extract_seqs_command = f'diamond getseq -d {diamond_db} > {eggnog_proteins_path}'
if not file_exists(eggnog_proteins_path):
print('Extracting sequences from Diamond database',flush=True,file=self.redirect_verbose)
print('Extracting sequences from NOG Diamond database',flush=True,file=self.redirect_verbose)
run_command(extract_seqs_command,join_command=True,shell=True)
return self.create_fastas_NOG_DMND()

Expand Down
28 changes: 15 additions & 13 deletions mantis/Exceptions.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
RequirementsNotMet='Installation check not passed! Make sure you\'ve setup the databases and your system meets all the requirements!'
NoValidFiles='No valid files to annotate'
TargetFileNotFound='Target file does not exist!\n'
InvalidTargetFile='You did not insert a valid target file!\n'
InvalidFastaFormat='Fasta format is not valid!\n'
InstallationCheckNotPassed='Installation check not passed! Make sure you\'ve setup the databases and your system meets all the requirements!'
SQLCheckNotPassed='SQL check not passed! Make sure you\'ve setup the databases and your system meets all the requirements!'
CythonNotCompiled= 'Cython has not been correctly compiled! Please run:\n'
BadNumberWorkers='You should not be seeing this, please contact the developer. Invalid number of workers in '
ConnectionError='Could not connect to url:\n'
InvalidTranslation='Invalid residues for translation. Please make sure you provided a CDS of DNA or RNA in the target file:\n'
InvalidGFFVersion='No valid GFF version found!'
InvalidNOGType='Your config file does not contain a valid database type for NOG (i.e. <dmnd> or <hmm>)!'

class RequirementsNotMet(Exception):
def __init__(self, *args):
if args:
self.message = args
else:
self.message = None



class SQLCheckNotPassed(Exception):
def __init__(self):
self.message = 'SQL check not passed!'
def __str__(self):
return self.message



class InstallationCheckNotPassed(Exception):
def __init__(self):
self.message = 'Installation check not passed! Make sure you\'ve setup the databases'
def __str__(self):
if self.message:
res = 'Requirements not met:\n'
res += '\n'.join(i for i in self.message)
return res
else:
return 'Requirements not met'
return self.message


0 comments on commit e4b01a7

Please sign in to comment.