Changed allele CSV output to non-lists
This commit is contained in:
		@@ -1,7 +1,6 @@
 | 
			
		||||
import csv
 | 
			
		||||
from io import TextIOWrapper
 | 
			
		||||
from os import PathLike
 | 
			
		||||
from typing import AsyncIterable, Iterable, Mapping, Sequence, Union
 | 
			
		||||
from typing import AsyncIterable, Mapping, Sequence, Union
 | 
			
		||||
 | 
			
		||||
from automlst.engine.data.structures.mlst import Allele, MLSTProfile
 | 
			
		||||
 | 
			
		||||
@@ -11,10 +10,11 @@ def dict_loci_alleles_variants_from_loci(alleles_map: Mapping[str, Sequence[Alle
 | 
			
		||||
    for loci, alleles in alleles_map.items():
 | 
			
		||||
        if len(alleles) == 1:
 | 
			
		||||
            result_dict[loci] = alleles[0].allele_variant
 | 
			
		||||
        for allele in alleles:
 | 
			
		||||
            result_locis = list()
 | 
			
		||||
            result_locis.append(allele.allele_variant)
 | 
			
		||||
            result_dict[loci] = result_locis
 | 
			
		||||
        else:
 | 
			
		||||
            for allele in alleles:
 | 
			
		||||
                result_locis = list()
 | 
			
		||||
                result_locis.append(allele.allele_variant)
 | 
			
		||||
                result_dict[loci] = result_locis
 | 
			
		||||
    return result_dict
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								tests/automlst/engine/data/local/test_csv.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/automlst/engine/data/local/test_csv.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
from automlst.engine.data.local.csv import dict_loci_alleles_variants_from_loci
 | 
			
		||||
from automlst.engine.data.structures.mlst import Allele
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_dict_loci_alleles_variants_from_loci_single_loci_not_list():
 | 
			
		||||
    alleles_map = {
 | 
			
		||||
        "adk": [Allele("adk", "1", None)]
 | 
			
		||||
    }
 | 
			
		||||
    results = dict_loci_alleles_variants_from_loci(alleles_map)
 | 
			
		||||
    for loci, variant in results.items():
 | 
			
		||||
        assert isinstance(variant, str)
 | 
			
		||||
        assert variant == "1"
 | 
			
		||||
		Reference in New Issue
	
	Block a user