@@ -452,10 +452,10 @@ def alleleupdater(self, sample, gene, targetallele):
452
452
return gene , allelenumber , 100.0 , hsp .score
453
453
454
454
def sequencetyper (self ):
455
+ """Determines the sequence type of each strain based on comparisons to sequence type profiles"""
455
456
for sample in self .metadata :
456
457
if sample .general .bestassemblyfile != 'NA' :
457
- if type (sample [self .analysistype ].allelenames ) == list :
458
- """Determines the sequence type of each strain based on comparisons to sequence type profiles"""
458
+ if len (sample [self .analysistype ].allelenames ) > 1 :
459
459
# Initialise variables
460
460
header = 0
461
461
# Iterate through the genomes
@@ -465,7 +465,6 @@ def sequencetyper(self):
465
465
self .bestmatch [genome ] = defaultdict (int )
466
466
if sample [self .analysistype ].profile != 'NA' :
467
467
# Create the profiledata variable to avoid writing self.profiledata[self.analysistype]
468
- # profiledata = self.profiledata[self.analysistype]
469
468
profiledata = sample [self .analysistype ].profiledata
470
469
# For each gene in plusdict[genome]
471
470
for gene in sample [self .analysistype ].allelenames :
@@ -583,7 +582,7 @@ def sequencetyper(self):
583
582
mismatches .append (
584
583
({gene : ('{} ({})' .format (self .bestdict [sample .name ][gene ]
585
584
.keys ()[0 ], sortedrefallele ))}))
586
- if not self .updateprofile :
585
+ if not self .updateprofile or self . analysistype == 'mlst' :
587
586
sample [self .analysistype ].mismatchestosequencetype = mismatches
588
587
sample [self .analysistype ].sequencetype = sequencetype
589
588
sample [self .analysistype ].matchestosequencetype = matches
@@ -607,7 +606,6 @@ def sequencetyper(self):
607
606
sample [self .analysistype ].sequencetype = 'NA'
608
607
609
608
def reprofiler (self , header , genome , sample ):
610
- # reprofiler(numGenes, profileFile, geneList, genome)
611
609
"""
612
610
Creates and appends new profiles as required
613
611
:param header:
@@ -1330,26 +1328,27 @@ def strainer(self):
1330
1328
# updatecall, allelefolder = '', '{}rMLST/holding'.format(self.referencefilepath)
1331
1329
self .alleles = glob ('{}/*.tfa' .format (allelefolder ))
1332
1330
# self.alleles = glob('{}/*.fas'.format(allelefolder))
1333
- self . profile = glob ('{}/*.txt' .format (allelefolder ))
1331
+ profile = glob ('{}/*.txt' .format (allelefolder ))
1334
1332
self .supplementalprofile = '{}rMLST/OLC_rMLST_profiles.txt' .format (self .referencefilepath )
1335
1333
self .combinedalleles = glob ('{}/*.fasta' .format (allelefolder ))
1336
1334
# Set the metadata file appropriately
1337
1335
sample [self .analysistype ].alleledir = allelefolder
1338
1336
sample [self .analysistype ].updatecall = updatecall
1339
1337
else :
1340
1338
self .alleles = glob ('{}MLST/{}/*.tfa' .format (self .referencefilepath , sample .general .referencegenus ))
1341
- self . profile = glob ('{}MLST/{}/*.txt' .format (self .referencefilepath , sample .general .referencegenus ))
1339
+ profile = glob ('{}MLST/{}/*.txt' .format (self .referencefilepath , sample .general .referencegenus ))
1342
1340
self .combinedalleles = glob ('{}MLST/{}/*.fasta' .format (self .referencefilepath ,
1343
1341
sample .general .referencegenus ))
1344
1342
sample [self .analysistype ].alleledir = '{}MLST/{}/' .format (self .referencefilepath ,
1345
1343
sample .general .referencegenus )
1346
1344
sample [self .analysistype ].alleles = self .alleles
1347
1345
sample [self .analysistype ].allelenames = [os .path .split (x )[1 ].split ('.' )[0 ] for x in self .alleles ]
1348
- sample [self .analysistype ].profile = self . profile
1346
+ sample [self .analysistype ].profile = profile if profile else 'NA'
1349
1347
sample [self .analysistype ].analysistype = self .analysistype
1350
1348
sample [self .analysistype ].reportdir = '{}/{}/' .format (sample .general .outputdirectory , self .analysistype )
1351
1349
sample [self .analysistype ].combinedalleles = self .combinedalleles
1352
- sample [self .analysistype ].supplementalprofile = self .supplementalprofile
1350
+ sample [self .analysistype ].supplementalprofile = self .supplementalprofile if self .supplementalprofile \
1351
+ else 'NA'
1353
1352
else :
1354
1353
# Set the metadata file appropriately
1355
1354
sample [self .analysistype ].alleles = 'NA'
0 commit comments