Questions tagged [dna]

The tag has no usage guidance.

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

Pset 6 - Dna - My outputs are slightly incorrect. Could someone help me figure out what might be the problem here?

I've been stuck on this question for a week. After countless hours of debugs, I decided to post it here. Please refer to images and code snippets below and kindly explain to me what might be the ...
1
vote
1answer
40 views

Minor change in pset6/dna required, need some help or hint

I am really really close to completing pset/dna. But there seems to be some problem in the 'if statement'. Somebody please guide. Before the line of underscores in the terminal, I have printed the ...
0
votes
1answer
39 views

pset6 DNA // having problem comparing elements from the database and the sequence file

Hi there I am having an issue comparing the data I have extracted from the sequence and the database files for now I am doing a sort of in efficient way but later I will fix it I am not sure really ...
0
votes
1answer
29 views

PSET6 DNA Almost done - matching not working correctly

I have been stuck with last part of the code that is supposed to match the DNA sequence from sequence.txt with the one in database.csv. It passes most of the tests in check50 and fails only in ...
0
votes
1answer
34 views

PSET6 DNA Think I'm getting an infinite loop which is apparent when testing with every txt file after 4.txt

Hi all I'm having trouble for PSET6 DNA. My code works fine for everything up until and including 4.txt but whenever I go to check the large.csv file and thus 5.txt, 6.txt, 7.txt and so on I seem to ...
0
votes
1answer
42 views

pset6 DNA works with small database but not with the large one

For some reason, when counting the times a substring repeats within a string (a STR in a DNA), my code fails with the large database. It is not a matter of overlapping sequences, because the numbers ...
0
votes
1answer
38 views

pset6 - DNA - works for small.csv but not large.csv

import csv import sys with open(sys.argv[1], 'r') as file: # stores data from small.csv in both dict and list form dna_names_dict = csv.DictReader(file) ...
0
votes
1answer
19 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
82 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
79 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
39 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
46 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
81 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
43 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
39 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
79 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 ...
-1
votes
0answers
49 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
22 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
118 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
60 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
116 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
93 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
175 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
84 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
39 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
63 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
229 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 ...
1
vote
0answers
94 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
156 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
46 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
193 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
115 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
98 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
115 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
124 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
51 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
47 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
42 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
51 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
137 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
203 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
103 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
242 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
335 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
89 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
169 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
103 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
63 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
196 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 ...