28
28
# Set up logging
29
29
blastutils_log = LogIt ().default (logname = "blast-utils" , logfile = None )
30
30
seqidlist_log = LogIt ().default (logname = "gi-lists" , logfile = None )
31
+ utils_log = LogIt ().default (logname = "utils" , logfile = None )
31
32
_datefmt = '%I:%M:%S %p on %m-%d-%Y'
32
33
_date = str (datetime .now ().strftime (_datefmt ))
33
34
@@ -445,17 +446,17 @@ def multi_fasta_manipulator(self, target_file, man_file, output_file,
445
446
# Create a new multi-fasta record object using the target_file,
446
447
# reference, and output
447
448
# Remove specific sequences from a fasta file
448
- if manipulation is 'remove' :
449
+ if manipulation == 'remove' :
449
450
self .multi_fasta_remove (target_file , man_file , new_file )
450
451
# Combine all the FASTA sequence in one record object
451
- elif manipulation is 'add' :
452
+ elif manipulation == 'add' :
452
453
self .muli_fasta_add (target_file , man_file , new_file )
453
454
# Sort one fasta file based on the order of another
454
455
# Works for alignments
455
- elif manipulation is 'sort' :
456
+ elif manipulation == 'sort' :
456
457
self .multi_fasta_sort (target_file , man_file , new_file )
457
458
458
- print ('A new fasta file has been created.' )
459
+ utils_log . info ('A new fasta file has been created.' )
459
460
return new_file
460
461
461
462
# def dir_config(path, tier_frame_dict):
@@ -505,7 +506,7 @@ def multi_fasta_remove(self, target_file, man_file, output_file):
505
506
target_file ,
506
507
'fasta' ) if record .id in ids )
507
508
508
- print ('Sequences have been filtered.' )
509
+ utils_log . info ('Sequences have been filtered.' )
509
510
SeqIO .write (new_records , str (output_file ), 'fasta' )
510
511
SeqIO .write (old_records , str (rem_file ), 'fasta' )
511
512
@@ -532,11 +533,11 @@ def muli_fasta_add(self, target_file, man_file, output_file):
532
533
target_file , 'fasta' , ), SeqIO .parse (man_file , 'fasta' ))
533
534
count = SeqIO .write (new_records , tmp_file , 'fasta' )
534
535
tmp_file .seek (0 )
535
- print ('temp file count: ' + str (count ))
536
+ utils_log . info ('temp file count: ' + str (count ))
536
537
SeqIO .write (SeqIO .parse (tmp_file , 'fasta' ), str (output_file ), 'fasta' )
537
- print ('Sequences have been added.' )
538
+ utils_log . info ('Sequences have been added.' )
538
539
else :
539
- print ('You can only add files together. Not python objects.' )
540
+ utils_log . warning ('You can only add files together. Not python objects.' )
540
541
541
542
def multi_fasta_sort (self , target_file , man_file , output_file ):
542
543
"""Sorts selected reference sequences in a multi-FASTA files.
@@ -569,15 +570,15 @@ def multi_fasta_sort(self, target_file, man_file, output_file):
569
570
for unsorted_aln_record in SeqIO .parse (target_file , 'fasta' ):
570
571
# If an appropriate id is found, then append to the MSA object.
571
572
if unsorted_aln_record .id == sorted_seq_record .id :
572
- print (unsorted_aln_record .id )
573
- print (sorted_seq_record .id )
573
+ utils_log . info (unsorted_aln_record .id )
574
+ utils_log . info (sorted_seq_record .id )
574
575
aln .append (unsorted_aln_record ) # MSA object
575
576
break
576
577
count = AlignIO .write (aln , tmp_file , 'fasta' )
577
578
tmp_file .seek (0 )
578
- print ('temp file count: ' + str (count ))
579
+ utils_log . info ('temp file count: ' + str (count ))
579
580
AlignIO .write (AlignIO .read (tmp_file , 'fasta' ), str (output_file ), 'fasta' )
580
- print ('Alignment has been sorted.' )
581
+ utils_log . info ('Alignment has been sorted.' )
581
582
582
583
583
584
class OrthologUtils (BlastUtils , GenbankUtils ):
@@ -877,7 +878,7 @@ def __init__(self, packagename):
877
878
def _getversion (self ):
878
879
import_module (self .packagename )
879
880
version = pkg_resources .get_distribution (self .packagename ).version
880
- print ('Version %s of %s is installed.' % (version , self .packagename ))
881
+ utils_log . info ('Version %s of %s is installed.' % (version , self .packagename ))
881
882
882
883
883
884
class FunctionRepeater (object ):
@@ -933,7 +934,7 @@ def system_cmd(self, cmd, timeout=None, print_flag=True,
933
934
for line in iter (proc .stdout .readline , "" ):
934
935
stdout_list .append (line .rstrip ())
935
936
if print_flag :
936
- print (line , end = "" )
937
+ utils_log . info (line , end = "" )
937
938
sys .stdout .flush ()
938
939
if write_flag :
939
940
with open (file_name , 'a' ) as output_file :
0 commit comments