Skip to content

Commit

Permalink
used logging instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Jan 6, 2018
1 parent b4fbfc8 commit e6fa946
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
6 changes: 5 additions & 1 deletion voseq/blast_local/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from subprocess import CalledProcessError

from django.shortcuts import render
Expand All @@ -7,6 +8,9 @@
from core.utils import BLAST


log = logging.getLogger(__name__)


def index(request, voucher_code, gene_code):
version, stats = get_version_stats()
username = get_username(request)
Expand All @@ -18,7 +22,7 @@ def index(request, voucher_code, gene_code):
try:
blast.create_blast_db()
except CalledProcessError:
print("there are no sequences for gene {}".format(gene_code))
log.warning("there are no sequences for gene {}".format(gene_code))

good_sequence = blast.save_query_to_file()
if good_sequence:
Expand Down
10 changes: 7 additions & 3 deletions voseq/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import glob
import logging
import os
import re
import subprocess
Expand All @@ -18,6 +19,8 @@
from public_interface.models import Sequences


log = logging.getLogger(__name__)


def get_voucher_codes(cleaned_data):
"""Processes list of voucher codes entered by users.
Expand Down Expand Up @@ -120,7 +123,8 @@ def clean_positions(a_list):
return ['1st-2nd']
elif len(a_list) == 2: # 1st and 3rd, or 2nd and 3rd
raise exceptions.InadequateCodonPositions(
"Cannot create dataset for only codon positions {0} and {1}.".format(a_list[0], a_list[1])
"Cannot create dataset for only codon positions {0} and {1}."
"".format(a_list[0], a_list[1])
)
else:
return a_list
Expand Down Expand Up @@ -235,15 +239,15 @@ def create_blast_db(self):
Optionally eliminates low-complexity regions from the sequences.
"""
print("Creating blast db")
log.debug("Creating blast db")
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.

command = 'makeblastdb -in ' + self.seq_file + ' -input_type fasta -dbtype nucl '
command += '-mask_data ' + self.seq_file + '_dust.asnb '
command += '-out ' + self.seq_file + ' -title "Whole Genome without low-complexity regions"'
command += '-out ' + self.seq_file + ' -title "Whole Genome without low-complexity regions"' # noqa
subprocess.check_output(command, shell=True) # Overwriting the genome file.
else:
command = 'makeblastdb -in ' + self.seq_file + ' -input_type fasta -dbtype nucl '
Expand Down
8 changes: 6 additions & 2 deletions voseq/genbank_fasta/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os

from django.contrib.auth.decorators import login_required
Expand All @@ -12,6 +13,9 @@
from create_dataset.utils import CreateDataset


log = logging.getLogger(__name__)


@login_required
def index(request):
version, stats = get_version_stats()
Expand Down Expand Up @@ -51,7 +55,7 @@ def results(request):

dataset_creator = CreateDataset(cleaned_data)
dataset = dataset_creator.dataset_str
dataset_short = dataset[0:1500] + '\n...\n\n\n' + '#######\nComplete dataset file available for download.\n#######'
dataset_short = dataset[0:1500] + '\n...\n\n\n' + '#######\nComplete dataset file available for download.\n#######' # noqa
errors = dataset_creator.errors
warnings = dataset_creator.warnings
dataset_file_abs = dataset_creator.dataset_file
Expand Down Expand Up @@ -98,7 +102,7 @@ def results(request):

@login_required
def serve_file(request, file_name):
print("Requested file by user: {0}".format(request.user))
log.debug("Requested file by user: {0}".format(request.user))
cwd = os.path.dirname(__file__)
fasta_file = os.path.join(cwd,
'..',
Expand Down
9 changes: 7 additions & 2 deletions voseq/public_interface/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from itertools import chain
import json
import logging

from django.contrib.auth.decorators import login_required
from django.db.models import Q
Expand All @@ -13,12 +14,16 @@
from haystack.query import ValuesSearchQuerySet

from core.utils import get_version_stats, get_username
from .utils import VoSeqSearchView, get_simple_query, get_correct_url_query, get_voucher_code_list
from .utils import get_simple_query, get_correct_url_query, get_voucher_code_list
from .models import Vouchers, FlickrImages, LocalImages, Sequences, Primers
from .forms import AdvancedSearchForm, BatchChangesForm


log = logging.getLogger(__name__)


def index(request):
log.debug("Index")
version, stats = get_version_stats()
username = get_username(request)

Expand Down Expand Up @@ -188,7 +193,7 @@ def search_advanced(request):
'result_count': len(sqs),
'version': version,
'stats': stats,
})
})
else:
return render(request, 'public_interface/search_results.html',
{
Expand Down
28 changes: 14 additions & 14 deletions voseq/voseq/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,59 +164,59 @@
'propagate': False,
},
'blast_local': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'blast_local_full': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'blast_ncbi': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'blast_new': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'core': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'create_dataset': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'gbif': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'genbank_fasta': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'gene_table': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'overview_table': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'public_interface': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'stats': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'view_genes': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
'voucher_table': {
'handlers': ['terminal', 'file', 'mail_admins'],
'handlers': ['terminal', 'file', 'file_debug', 'mail_admins'],
'level': 'DEBUG',
},
},
Expand Down

0 comments on commit e6fa946

Please sign in to comment.