import csv
import sys
counter = 0
def main():
if len(sys.argv) != 3:
sys.exit("Usage: python dna.py data.csv sequence.txt")
# Open csv file and read it's contents into memory
str_sequence = {
"AGATC" : 0,
"TTTTTTCT" : 0,
"AATG" : 0,
"TCTAG" : 0,
"GATA" : 0,
"TATC" : 0,
"GAAA" : 0,
"TCTG" : 0
}
dna_data = []
with open(sys.argv[1]) as file:
reader = csv.DictReader(file)
for row in reader:
dna_data.append(row)
# Open the text file and read it's contents into memory
sequences = []
file2 = open(sys.argv[2])
for pie in file2:
file2.read()
sequences.append(pie)
countsss = get_strcounts()
print(countsss)
def get_strcounts(sequences, str_sequence):
for i in sequences:
for pie in str_sequence:
if (sequences[0:i] == str_sequence[pie]):
counter += 1
return counter
main()
I could really use some explanation about this problem set. I am having a hard time with this transition from C to python and I would appreciate the help. I am really not able to understand how I can get the highest consecutive counts of strs and how I am supposed to actually use the function. Because for now I am just printing out the count to see if my code is correct but it gives nothing in the output.
longest_match()
. Did you see it in thedna.py
template file? You can use it to get length of longest run of a subsequence (e.g. "AGATC") in the complete DNA sequence. So, you don't need to writeget_strcounts()
. Note: indentation/formatting needs to be fixed in code above.