0
from sys import argv, exit
import pandas as pd


# Checks if the number of files is correct
if len(argv) != 3:
    print("Usage: python dna.py data.csv sequence.txt")
    exit(1)

# Reads the text file
f = open(argv[2], "r")
sequences = f.readline()
f.close()

# Returns the longest sequences in a dictionary


def patterns(a, b, c):

    STRs = {a: 0, b: 0, c: 0}
    counter = 0
    text_accumulator = ""

    for idx, char in enumerate(sequences):

        text_accumulator += char

        for key in STRs.keys():

            if idx + 1 + len(key) <= len(sequences) - 1:
                if key in text_accumulator:
                    counter += 1
                    text_accumulator = ""

                    if sequences[idx + 1: idx + 1 + len(key)] == key:
                        continue
                    else:
                        if STRs[key] < counter:
                            STRs[key] = counter
                        counter = 0

    return STRs


# Compares the sequences with the database in the CSV file
DNA_person = patterns("AGATC", "TATC", "AATG")
df = pd.read_csv(argv[1])
df = df.loc[(df["AGATC"] == DNA_person["AGATC"]) & (df["TATC"] == DNA_person["TATC"]) & (df["AATG"] == DNA_person["AATG"])]


# Prints the results
if df.empty:
    print("No match")
for i, row in df.iterrows():
    print(row["name"])
0

Looks like you are only comparing 3 STR for everyone. As DinoCoderSaurus stated, there are 8 for that one, not just the 3 you have indicated in the code.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .