diff --git a/voseq/blast_local/utils.py b/voseq/blast_local/utils.py index dda78079..6f1aefc8 100644 --- a/voseq/blast_local/utils.py +++ b/voseq/blast_local/utils.py @@ -79,7 +79,7 @@ def is_blast_db_up_to_date(self): :return: True or False """ - if self.have_blast_db() is False: + if not self.have_blast_db(): return False # get time creation blast database files @@ -132,7 +132,7 @@ def create_blast_db(self): """ print("Creating blast db") - if self.mask is True: + if self.mask: command = 'dustmasker -in ' + self.seq_file + ' -infmt fasta ' command += '-outfmt maskinfo_asn1_bin -out ' + self.seq_file + '_dust.asnb' subprocess.check_output(command, shell=True) # identifying low-complexity regions. diff --git a/voseq/blast_local/views.py b/voseq/blast_local/views.py index d41484d1..130ff605 100644 --- a/voseq/blast_local/views.py +++ b/voseq/blast_local/views.py @@ -12,7 +12,7 @@ def index(request, voucher_code, gene_code): blast = BLAST('local', voucher_code, gene_code) blast.save_seqs_to_file() - if blast.is_blast_db_up_to_date() is False: + if not blast.is_blast_db_up_to_date(): blast.create_blast_db() blast.save_query_to_file() diff --git a/voseq/blast_local_full/views.py b/voseq/blast_local_full/views.py index 0e63a3b3..f5925ef9 100644 --- a/voseq/blast_local_full/views.py +++ b/voseq/blast_local_full/views.py @@ -12,7 +12,7 @@ def index(request, voucher_code, gene_code): blast = BLASTFull('full', voucher_code, gene_code) blast.save_seqs_to_file() - if blast.is_blast_db_up_to_date() is False: + if not blast.is_blast_db_up_to_date(): blast.create_blast_db() blast.save_query_to_file() diff --git a/voseq/blast_new/views.py b/voseq/blast_new/views.py index 64c2a9e9..d1819ee5 100644 --- a/voseq/blast_new/views.py +++ b/voseq/blast_new/views.py @@ -36,7 +36,7 @@ def results(request): cleaned_data['gene_codes']) blast.save_seqs_to_file() - if blast.is_blast_db_up_to_date() is False: + if not blast.is_blast_db_up_to_date(): blast.create_blast_db() blast.save_query_to_file() diff --git a/voseq/create_dataset/utils.py b/voseq/create_dataset/utils.py index 24ba7ac5..97a4e36e 100644 --- a/voseq/create_dataset/utils.py +++ b/voseq/create_dataset/utils.py @@ -65,11 +65,11 @@ def __init__(self, cleaned_data): self.dataset_str = self.create_dataset() def clean_translations(self): - if self.cleaned_data['translations'] is False: + if self.cleaned_data['translations']: + self.degen_translations = self.cleaned_data['degen_translations'] + else: # No need to do degen translation self.degen_translations = None - else: - self.degen_translations = self.cleaned_data['degen_translations'] def create_dataset(self): if not self.codon_positions: diff --git a/voseq/public_interface/forms.py b/voseq/public_interface/forms.py index e67536cc..ab6b6ec7 100644 --- a/voseq/public_interface/forms.py +++ b/voseq/public_interface/forms.py @@ -140,11 +140,10 @@ def no_query_found(self): def search(self): keywords, sequence_keywords = self.clean_search_keywords() sqs = '' - if bool(sequence_keywords) is True: + if sequence_keywords: sqs = SearchQuerySet().using('advanced_search').filter(**sequence_keywords).facet('code') sqs = filter_results_from_sequence_table(sqs) - if bool(keywords) is True: - print(keywords) + if keywords: if sqs != '': sqs = sqs.filter(**keywords) else: diff --git a/voseq/public_interface/management/commands/_migrate_db.py b/voseq/public_interface/management/commands/_migrate_db.py index 5fbfced5..ee4f3bdf 100644 --- a/voseq/public_interface/management/commands/_migrate_db.py +++ b/voseq/public_interface/management/commands/_migrate_db.py @@ -29,7 +29,7 @@ TZINFO = pytz.utc -if settings.TESTING is True: +if settings.TESTING: TESTING = True else: TESTING = False @@ -73,7 +73,7 @@ def parse_image_info(self, item): item['thumbnail'] = self.get_as_tuple(item['thumbnail'], got_flickr) imgs = [] - if got_flickr is True and item['flickr_id']: + if got_flickr and item['flickr_id']: item['flickr_id'] = self.get_as_tuple(item['flickr_id'], got_flickr) for i in range(0, len(item['voucher_image']), 1): @@ -102,7 +102,7 @@ def parse_table_genes(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_genes_items = [] @@ -131,7 +131,7 @@ def parse_table_genesets(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_genesets_items = [] @@ -157,7 +157,7 @@ def parse_table_members(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_members_items = [] @@ -187,7 +187,7 @@ def parse_table_primers(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_primers_items = [] @@ -221,7 +221,7 @@ def parse_table_sequences(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_sequences_items = [] @@ -248,7 +248,7 @@ def parse_table_taxonsets(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_taxonsets_items = [] @@ -271,7 +271,7 @@ def parse_table_vouchers(self, xml_string): our_data = i break - if our_data is False: + if not our_data: raise ValueError("Could not find table {} in database dump file.".format(this_table)) self.table_vouchers_items = [] @@ -491,10 +491,10 @@ def save_table_members_to_db(self): user = User.objects.create_user(item['username'], email=None, first_name=item['first_name'], last_name=item['last_name']) user.is_staff = True - if item['is_superuser'] is False: - user.is_superuser = False - else: + if item['is_superuser']: user.is_superuser = True + else: + user.is_superuser = False user.save() if not TESTING: @@ -535,7 +535,7 @@ def save_table_sequences_to_db(self): seqs_invalid = [] for i in self.table_sequences_items: validation = validate_sequence(i['sequences']) - if validation.is_valid is False: + if not validation.is_valid: ProblematicSequence = namedtuple('ProblematicSequence', ['code', 'gene_code', 'invalid_character']) prob_seq = ProblematicSequence(i['code_id'], i['gene_code'], validation.invalid_character) @@ -551,7 +551,7 @@ def save_table_sequences_to_db(self): print("\nUploading table `public_interface_sequences`") n = len(seqs_to_insert) - if TESTING is False: + if not TESTING: bar = pyprind.ProgBar(n, width=70) seqs_objects = [] @@ -565,7 +565,7 @@ def save_table_sequences_to_db(self): item = self.clean_value(item, 'sequences') item = self.clean_value(item, 'accession') seqs_objects.append(Sequences(**item)) - if TESTING is False: + if not TESTING: bar.update() if not TESTING: @@ -611,7 +611,7 @@ def save_table_vouchers_to_db(self): voucher_objs = [] n = len(self.table_vouchers_items) - if TESTING is False: + if not TESTING: bar = pyprind.ProgBar(n, width=70) for i in range(n): item = self.table_vouchers_items[i] @@ -645,7 +645,7 @@ def save_table_vouchers_to_db(self): voucher_objs.append(Vouchers(**item)) - if TESTING is False: + if not TESTING: bar.update() Vouchers.objects.bulk_create(voucher_objs) @@ -689,10 +689,10 @@ def get_as_tuple(self, string, got_flickr=None): return as_tupple def strip_domain_from_filename(self, item, got_flickr=None): - if got_flickr is False: + if not got_flickr: disassembled = parse.urlsplit(item) return basename(disassembled.path) - elif got_flickr is True: + elif got_flickr: return item else: return None