Questions tagged [dna]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
17 views

Index to integer

How do i convert an index to an integer? I tried int(index), that didnt work. For example; S = [a,b,c,d] For index in S: n = int(index) print (n) break print ()
0
votes
0answers
56 views

pset6 dna question regarding searching string for substring, two types of code give different output

I am currently following along ayoutube tutorial for pset 6 DNA, and have a small question regarding a specific function. In this function, it basically takes a substring and a string, and counts the ...
0
votes
1answer
68 views

Getting ONE error on check50 for DNA - ValueError: max() arg is an empty sequence - Where is the bug?

I'm so close the finish line, but I get error on one out of the 21 CS50 tests. The test that is generating the error is number #2, which is: python dna.py databases/small.csv sequences/2.txt And I ...
0
votes
1answer
28 views

DNA - Getting the highest key value from a defaultdict

I have come a bit on DNA and have managed to write an algorithm for adding the number of matches in the sequence to a defaultdict. But I'm having problems with how to get the maximum value from the ...
0
votes
0answers
35 views

CS50 PSET 6 DNA Just Returns First Name

I've been working on DNA for a while now and thought I was done, but there's a problem with my code. Everytime I run it, the program just prints the first name on the database, so either 'Albus' or '...
0
votes
1answer
61 views

PSET 6 DNA - Computing STRs

I am trying to compute the most repeated STR for each sequence in a dictionary called str_dict. # compute STRs i = 0 # stablish length of the sequence length_seq = len(sequence) # iterate through all ...
0
votes
0answers
37 views

DNA pset6 My code works fine in small csv, but not large (Spoiler)

The problem happens with the count when i try to count STRs, it counts some str right and some wrong, which is strange for me, and when i deal with small csv all works fine. can someone help me in ...
0
votes
1answer
34 views

Print keys of CSV files in DNA pset6

I want to see what the keys of the reader dictionary are so I use the print(key) function. The result is all the lines of the dictionary. Why is that? import csv from sys import argv, exit # Check if ...
0
votes
1answer
63 views

Computing consecutive STR is sometimes off by a little (Spoiler!)

My code works fine for the small csv file; however, when I get to the big csv file, my counts for the number of consecutive STR are less than the actual value by about 1 or 2. Here is my code: import ...
0
votes
0answers
43 views

DNA works with most names except Alice and Albus

I really don't undersrtand why this is happening. I'm trying to finish DNA for pset6. Since more elegant methods were too difficult for me, I decided to compare all values in STR one by one against ...
0
votes
0answers
21 views

DNA code can't count

My program always return 'no match' and it's because it can't count the occurence of a substring. I have spent a lot of time trying to figure it out, so I hope someone can help me. here's the function....
0
votes
1answer
109 views

pset6 count STR in the DNA sequence issues

so i m a bit confused...i have been testing my code using the small database and what i have so far produced what i expected .... more specifically the STRcounts (i marked that part #?????). it is ...
0
votes
0answers
59 views

Can't figure out how to fix my code, any help please?

# open the CSV file and read its contents into memory with open(argv[1], newline = '') as csvfile: readCSV = list(csv.reader(csvfile)) for raw in readCSV: pass # Your program should ...
0
votes
0answers
97 views

pset6 DNA only getting “no match” SPOILER

I'm new to programming and have been stuck on the pset6 DNA assignment for a long time. The code outputs "no match" for everything, even though the output numbers from calculating the STR ...
0
votes
0answers
85 views

I'm stack with dna (pset6). can you please help me?

I have divided my code into three main pieces: 1- open the CSV file and read its contents into memory and open the DNA sequence and read its contents into memory 2- compute the longest run of ...
0
votes
1answer
161 views

PSET 6 DNA: How to get number of repeats for each value of STR's? [SPOILER: Full code]

I have written a code to count the highest number of consecutive repeats of specific DNA substring sequences in a long string of DNA...or so I thought. While my code can correctly count the longest ...
0
votes
1answer
73 views

DNA: Errors in sequences.3 and 18.txt

I have worked hard on writing codes for DNA. Everything works except for sequences/18.txt, which returns "Harry" instead of "No match". The problem still exists in spite of several ...
0
votes
0answers
36 views

DNA.py error: 'TypeError: unsupported operand type(s) for *: 'NoneType' and 'int''. It passes all but 2 of the tests

DNA.py is nearly finished, but it is failing the tests with sequence/15.txt and 16.txt. This is the error message: ~/pset6/dna/ $ python dna.py databases/large.csv sequences/16.txt Traceback (most ...
0
votes
1answer
62 views

Issue with recording STRs in memory (PSET6 - DNA)

I'm trying to record the number of repetitions of each str in the sequence. I created a dictionary as below and another empty dict because i couldn't update a dict while iterating through it. But for ...
0
votes
1answer
215 views

Struggling with PSET6 DNA

I've been doing this for quite some time now, but I'm struggling to get the appropriate output. In the below code (which is incomplete as of now, but the main pieces are all on the board), I'm not ...
0
votes
0answers
79 views

PSET 6 DNA ~ some STR count is above the correct value by 1?

I'm almost done with pset6 hopefully but I have one problem with my code When i run it with for example python dna.py databases/small.csv sequences/4.txt python dna.py databases/large.csv sequences/10....
0
votes
1answer
137 views

Pset6 DNA Not matching to names in the database

The print statements seem to turn out what I hoped for up until trying to compare the STR counts to the database STR counts. I would just appreciate any pointers of where I'm going wrong thanks. ...
1
vote
1answer
43 views

Unexpected error in homemade string search function

I am playing around with Python on the DNA problem. I realize there are some string methods that might make this problem easier but my gut instinct was to try and make an "search function" ...
0
votes
0answers
43 views

DNA Pset6 Can't run my program

I cant even run my program it keeps saying "list index out of range". I don't know whats wrong... Does anyone have any idea? import sys import csv def repeats(seq, part): rep = [0] * ...
0
votes
1answer
159 views

Pset6 DNA help - trouble calculating STR repeats with long database

I have really tried to just solve this one myself but after a few weeks this seems futile without guidance. I am having trouble getting a for loop to calculate the maximum consecutive occurrences of ...
0
votes
0answers
111 views

PSET6 DNA [SPOILER] Refactor

I have solved the problem however is there anyway to optimize this further? Also, how do I judge the time-space complexity of the same? import csv from sys import argv, exit from csv import reader, ...
0
votes
0answers
89 views

Confused about DNA in pset6

I've just started DNA, and I've got what seems to be a working algorithm to see if the count of the STRs in the database and sequence are the same, but it does not seem to be working. I've been a bit ...
0
votes
0answers
109 views

PSET 6 DNA! Stuck for so long

so the problem I face is when computing the greatest number of STR's in a sequence. I was able to hardcode "GATA" and compute the greatest sequence for a textfile using my sequencecount ...
0
votes
0answers
113 views

cs50 pset6 DNA, minor differences in counting STRs |Spoiler entire code included|

My code counts STRs for some people correctly, but for others the difference is very small. For example for python dna.py databases/large.csv sequences/5.txt expected output is Luna, whose STR counts ...
0
votes
1answer
49 views

Desperately need help with DNA Python! please help!

Desperately need help with my DNA python code. I get the correct sequence printed out but I can't seem to find a working comparison code. Please someone take a look: https://pastebin.com/DCdxtxMx
0
votes
1answer
45 views

Help with Python DNA!

Here is the code I have an issue with: https://i.ibb.co/0VrvCqj/code2.jpg It works for small databases but not the big ones. Here the code works and shows Albus when it should show Lavander. As you ...
0
votes
0answers
41 views

How can I compare 2 dataframes on DNA?

obtained 2 data frames but I really don't know how can I compare them. Do you have any ideas? ~/pset6/dna/ $ python dna.py databases/small.csv sequences/1.txt name AGATC AATG TATC 0 0 4 1 ...
0
votes
0answers
49 views

SPOILER - CS50: Python PSET6. How do I ensure that my code does not show 1 and 2?

I am about halfway done with my python Pset6 code for DNA. One problem I have been having is that without this particular line of code below: lresults = [i for i in lresults if i != '1' and i != '2'] ...
0
votes
1answer
133 views

PS6 - DNA (Python) Weird problem counting STRs

Which part of the problem are you working on? I am at a very early stage of the problem, trying to scan a specific sequence for STRs, counting how many times they show up and storing this count as a ...
0
votes
1answer
196 views

PSET6 DNA only getting no match

I've been stuck on this pset for days, trying to get some help here :x Basically my program only outputs no match no matter what I do. I tested my re.finditer separately and it prints out what I want, ...
0
votes
1answer
102 views

Else is ruining my code in dna and I don't get why

I'm trying to record the longest run of each STR I need and I'm close. Without the final "else" the code works fine with small dictionary and almost fine with long (because the count I ...
0
votes
1answer
240 views

My code is 95% correct and I can't understand why. Why, Harry? WHY?

I can't figure out why just only one is not correct. I really need to understand this. Please, help me import sys import csv # Open sequence file sequence_file = open(str(sys.argv[2]), 'r') ...
0
votes
1answer
310 views

PSET6: DNA returns “no match”

import csv import sys def maxrepeats(sequences, substring): # calculate maximum consecutive frequency for each STR repeats = [0] * (len(sequences)+1) for i in range(len(sequences)-len(...
0
votes
1answer
84 views

pset6 DNA - range() not working as expected

DNA was a breeze until I got to the part where I have to check the dna sequences for patterns. Regardless of wich file I pass to the program it always detects only 1 repetition for every pattern. ...
0
votes
1answer
164 views

PSet 6: DNA gives correct as well as wrong ouput

Problem Set 6: DNA gives output No Match No Match No Match No Match No Match No Match No Match No Match No Match No Match Lavender No Match No Match No Match No Match No Match No Match No Match No ...
0
votes
0answers
98 views

PSET6 - DNA - Code works for small database, but not large

I believe that the issue comes from my 'sequencing' function. When I run the small database, everything works, however, when I run the large database, the counts of specific STRs are incorrect. I'm ...
0
votes
0answers
60 views

Can you help me making my pset6's 'dna' more dynamic

I want suggestions on how to manage my so many lists in the loops. Hello helpful soul, I actually can't figure out how I can declare lists more dynamically, and thus using them in the loops easily. ...
0
votes
0answers
171 views

PSET6 DNA algorithm help and comparing data

I've really struggled with DNA trying to come up with a good algorithm. I have half my code written, but I have no idea how to compare the data in the Dict with the CSV file. Any thoughts would be ...
1
vote
0answers
72 views

PSET6: dna.py, updating dictionary

I'm struggling with Python, specifically adding/updating keys and values in a dictionary. This is my code so far (I know it's probably far from perfect, this is my first time working with Python, ...
0
votes
0answers
71 views

Using csv.reader and csv.DictReader on the same file

I'm working on pset6 - DNA. My code is a work in progress, but the part I'm having trouble with is at the bottom. Right now I'm running without cmd line arguments, so I'm opening 1.txt and small.csv. ...
0
votes
1answer
137 views

Pset6, DNA - Convert all columns in a list to integers, skipping the first column

I'm trying to figure out how to take the csv file I opened and convert specific columns to ints since when the csv is opened and read, every element becomes an int. Inside of the for row in csv_list:...
0
votes
1answer
48 views

Counter fails to update for DNA

My dna program always returns no match and after debugging it I've pin pointed the problem to the counter not updating correctly. My program finds the correct number of matches, which I've confirmed ...
0
votes
1answer
310 views

DNA pset6 - Unable to calculate maximum STR repeats in DNA file

Below is my code for PSET6 DNA: from sys import argv import csv # "string" represents the DNA chain and "substring" represents an individual STR e.g. "ACTGC" def maxrepeats(string, substring): ...
0
votes
0answers
100 views

DNA is good for the small database but not for the large database - CS50 Pset6

I'm currently developing the small and the large database functions separately and I wonder why in the large one it does not keep track of the STR repetitions. Here is my code from both functions: ...
0
votes
0answers
102 views

solved pset6 BUT still wondering

while reading the CSV file in these lines : csv_file = open(sys.argv[1], "r") # reading the csv file into memoery csv_reader = csv.DictReader(csv_file) when i tried to make a copy of the csv_reader ...