From 7e6b73090f0ad1436101492848980c4403daa941 Mon Sep 17 00:00:00 2001 From: amos Date: Thu, 21 Sep 2023 11:14:02 -0400 Subject: [PATCH] adds code to create config file and add badge --- README.rst | 5 +++++ app/Database.py | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index c91a4d3..97b049b 100644 --- a/README.rst +++ b/README.rst @@ -5,6 +5,11 @@ :scale: 100% :target: https://travis-ci.org/arpcard/rgi +.. |build-status| image:: https://github.com/arpcard/rgi/actions/workflows/build.yml/badge.svg?branch=master + :alt: Workflow status badge + :scale: 100% + :target: https://github.com/arpcard/rgi/actions/workflows/build.yml + .. |docs| image:: https://img.shields.io/badge/install%20with-bioconda-brightgreen.svg?style=flat :alt: Documentation :scale: 100% diff --git a/app/Database.py b/app/Database.py index 64bd3a5..34482c2 100644 --- a/app/Database.py +++ b/app/Database.py @@ -20,10 +20,20 @@ def __repr__(self): def build_databases(self): """Build BLAST and DIAMOND databases.""" self.write_fasta_from_json() + self.create_blast_config() self.make_blast_database() self.make_diamond_database() self.write_fasta_from_json_rna() + def create_blast_config(self): + """ + This function stops NCBI application from sending usage report (which it does by default). + For more information see https://www.ncbi.nlm.nih.gov/books/NBK569851 + """ + config_file="{path}".format(path=os.path.join(self.db,".ncbirc")) + logger.info("config_file: {}".format(config_file)) + os.system("echo 'export BLAST_USAGE_REPORT=false' >> {config_file}".format(config_file=config_file)) + def make_blast_database(self): """Build BLAST database from a FASTA file.""" if os.path.isfile(os.path.join(self.db,"proteindb.fsa")) == True and os.path.exists(os.path.join(self.db,"proteindb.fsa")) == True \ @@ -176,7 +186,7 @@ def write_fasta_from_json_rna(self): for seq in j[i]['model_sequences']['sequence']: if j[i]['model_sequences']['sequence'][seq]['dna_sequence']['strand'] == "-": basecomplement = self.complementary_strand(j[i]['model_sequences']['sequence'][seq]['dna_sequence']['sequence']) - + fout.write('>%s_%s | model_type_id: 40295 | pass_bit_score: %s | SNP: %s | %s\n' \ % (i, seq, pass_bit_score, ','.join(snpList), j[i]['ARO_name'])) fout.write('%s\n' % (basecomplement)) @@ -202,11 +212,8 @@ def complementary_strand(self, strand): "R":"Y", "Y":"R", "S":"S", "W":"W", "B":"V", "V":"B", "H":"D", "D":"H"} complement = [] - for base in strand: + for base in strand: complement.append(self.trans[base]) - + complement_seq = ''.join(complement) return complement_seq - - -