0

I started to do DNA and I dont't have any idea what to do next. Having done the first part with opening a file and checking command line I don't know how to check number of repetitions. I tried to use substring s[i:j] but it gave me a result when I hardcoded earlier that I would search for repetitions of for example "AGATC". I also tried to use regular expressions but result is the same. Could you give me some hints ? Here's what I already wrote.

import cs50
import sys
import csv
import re

#check command line argument
if len(sys.argv)!=3:
print ("Usage: python dna.py data.csv sequence.txt")

#open csv file with names and numbers of repetitions
with open(sys.argv[1], "r") as csvfile:
  dna_data = csv.reader(csvfile)
  rows = list(dna_data)
  sequences_names = rows[0]

#open a file with sequences
file = open(sys.argv[2],"r")
sequence = file.read()
print(sequence)

#get each title of sequence which is to be searched for
for i in range(1,(len(rows[0]))):
   print(f"Titles {rows[0][i]}")

You must log in to answer this question.

Browse other questions tagged .