Beispiel #1
0
def isMutant():
    content = request.json
    usebase = 'nobase' not in content
    #print( content )
    stats = Stats(dna=request.data)

    if usebase:
        stat = stats.getByDNA()
    else:
        print('ignoring base')
        stat = None

    if stat is None:
        if 'dna' not in content:
            stats.isMutant = False
        else:
            stats.isMutant = ADN.isMutant(content['dna'])
        if usebase:
            stats.saveStat()
    else:
        #print('already exists')
        stats = stat

    if stats.isMutant:
        response = app.response_class(response=json.dumps({'mutante': True}),
                                      status=200,
                                      mimetype='application/json')
    else:
        response = app.response_class(response=json.dumps({'mutante': False}),
                                      status=403,
                                      mimetype='application/json')

    return response
Beispiel #2
0
 def testDiagonal2(self):
     data = {
         "dna": [
             "TAGCTAGCTA", "AGCTAGCTAT", "GCTAGCTATC", "CTAGCTATCG",
             "TAGCTATCGA", "AGCTATCGAT", "GCTATCGATC", "CTATCGATCG",
             "TATCGATCGA", "ATCGATCGAT"
         ]
     }
     assert True == ADN.isMutant(data['dna'])
Beispiel #3
0
 def testVertical(self):
     data = {
         "dna": [
             "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT",
             "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT",
             "ATCGATCGAT", "ATCGATCGAT"
         ]
     }
     assert True == ADN.isMutant(data['dna'])
Beispiel #4
0
 def testHorizontal(self):
     data = {
         "dna": [
             "AAAAAAAAAA", "TTTTTTTTTT", "CCCCCCCCCC", "GGGGGGGGGG",
             "AAAAAAAAAA", "TTTTTTTTTT", "CCCCCCCCCC", "GGGGGGGGGG",
             "AAAAAAAAAA", "TTTTTTTTTT"
         ]
     }
     assert True == ADN.isMutant(data['dna'])
Beispiel #5
0
 def testmissmatch(self):
     data = {"dna": ["AAAAAA", "AAAAA", "AAAA", "AAA", "AA", "A"]}
     assert False == ADN.isMutant(data['dna'])
Beispiel #6
0
 def testNonAllowed(self):
     data = {"dna": ["ATzG", "CAxG", "TTcA", "AGvA", "GhCG", "TyCA"]}
     assert False == ADN.isMutant(data['dna'])
Beispiel #7
0
 def testMin(self):
     data = {"dna": ["ATG", "CAG", "TTA", "AGA", "GCG", "TCA"]}
     assert False == ADN.isMutant(data['dna'])
Beispiel #8
0
 def testEmpty(self):
     assert False == ADN.isMutant([])
Beispiel #9
0
 def testNull(self):
     assert False == ADN.isMutant(None)
Beispiel #10
0
 def testEnunciadoNoMutante(self):
     data = {
         "dna":
         ["ATGCGA", "CAGTGC", "TTATTT", "AGACGG", "GCGTCA", "TCACTG"]
     }
     assert False == ADN.isMutant(data['dna'])
Beispiel #11
0
 def testEjemploMutante(self):
     data = {
         "dna":
         ["ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG"]
     }
     assert True == ADN.isMutant(data['dna'])