Skip to main content

Questions tagged [dna]

The tag has no usage guidance.

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

PSET6 DNA Sumbit50 not matching with usual output

Hello, After a lots of effort I was finally able to implement DNA and it works correctly ! but Submit50 shows correct output for text file (1-5) but incorrect for rest The text file which have ...
0 votes
1 answer
328 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
2 answers
29 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
2 answers
88 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
1 answer
33 views

My code look correct and work correctly for all other sequence but check50 says sequence/18 is wrong, expected "No match" not harry

import csv import sys global y def main(): y = 0 x = 0 t = 0 # Check for command-line usage if len(sys.argv) != 3: sys.exit("Usage: python dna.py data.csv sequence....
0 votes
2 answers
123 views

cs50 pset6 takes too long to run

I am trying to improve my code for pset6, it works but currently takes a few minutes for the larges files. Can I get some help as to how to improve performance? from sys import argv, exit import csv ...
0 votes
1 answer
224 views

My DNA code works with the small database but not the large one

My code works perfectly fine with the small database but gives "No Match" for the large one and I can't figure out why. Any help would be appreciated! import csv from sys import argv, exit def main()...
1 vote
1 answer
65 views

DNA: Excluding a column from my dict iteration

Logic: I'm trying to do this in such a way that I check the database first, then I check the DNA sequence to see if that information corresponds to any of the information in my database. I want to ...
0 votes
1 answer
591 views

PSET 6 DNA.py wrong output [spoiler]

I am a beginner in cs50 and I have a problem with the DNA problem that gives the wrong result for most of the queries. I wonder if anyone could point where is the mistake. ie. python dna.py databases/...
0 votes
1 answer
247 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
1 answer
112 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
1 answer
328 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
1 answer
2k views

cs50 pset 6 DNA. How to compare my results with the databse to print out the answer?

I got to a point in this problem where my code was working alright for the small csv, but it was clumsy and repetitive, so I tried to make it more elegant by making more complicated nested loops to ...
0 votes
1 answer
180 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 ...
1 vote
1 answer
46 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
1 answer
63 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
1 answer
279 views

CS50 DNA prints "No match"

My pset has some issues,can you please tell me what do i have to change in the main function in order to print name of longest DNA matched person. import csv import sys def main(): # TODO: Check for ...
0 votes
2 answers
128 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
1 answer
93 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
0 answers
33 views

cs50 dna pset 6 - i dont get why my code always return no match

this is my code. whenever i run this code it always returns no match. i cant seem to get the error. pls help me. import csv import sys def main(): # TODO: Check for command-line usage if ...
0 votes
1 answer
763 views

pset6 DNA. My code passes all tests but this one: python dna.py databases/large.csv sequences/18.txt

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 ...
0 votes
1 answer
70 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
1 answer
194 views

cs50 pset6 dna error while reading two file 8.txt and 9.txt

import sys import csv AATG, GATA, TATC, TCTG, AGATC, GAAA, TCTAG = 1, 1, 1, 1, 1, 1, 1 TTTTTTCT = 1 temp = 0 if int(len(sys.argv)) > 3 or int(len(sys.argv)) < 3: print("Usage: python dna.py ...
0 votes
1 answer
185 views

pset6 DNA: check50 ran into an error while running checks! at checking 'dna.py exists!'

The code runs for all 20 sequences on the terminal but during submit50/check50, it runs into an error with the following log: the code is attached for reference. import csv import sys if __name__ ==...
0 votes
1 answer
99 views

My code looks and works correctly but check50 fails

import csv import sys global y def main(): y = 0 x = 0 # Check for command-line usage if len(sys.argv) != 3: sys.exit("Usage: python dna.py data.csv sequence.txt") ...
1 vote
1 answer
304 views

PSET6: DNA check50 expecting no match on txt18 ,but my program returns harry

my code works for all the other tests on check50 besides the one for txt18. I checked the Large.csv file and the return value of longest_match function (both provided by cs50) and they match up yet ...
0 votes
1 answer
33 views

PSET6 DNA storing STR subsequences in a dictionary

I am working on one of the TODOs where the longest match of each short tandem repeat (STR) needs to be found from the DNA sequence read—written as just "sequence" in this code. To check ...
0 votes
1 answer
127 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
1 answer
164 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
1 answer
270 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. ...
0 votes
1 answer
23 views

PSET 6 - DNA - Checking the equality of STRs

This is my loop to check the equality of STR counts, csv list is a list storing data of the csv file and STRlist is a list storing all the STRs. It prints the wrong name, I guess it has something to ...
0 votes
1 answer
8 views

PSET 6 - DNA - Is there something wrong with my if statement?

The individual conditions are satisfied as checked by print statement, but when I consolidate all conditions in my if statement, the does'nt seem to print the name. Any ideas?, is there something ...
0 votes
1 answer
328 views

pset6 DNA - help creating and referencing dictionaries

This may be a strange question - my code actually worked, but I feel like I got to a solution by brute force, rather than something more elegant. I'm still not sure how to create and reference ...
0 votes
1 answer
436 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
1 answer
176 views

DNA - String Compare

I have a question about DNA, specifically this while statement: while dna_string[char: char + length_str] == dna_string[char - length_str: char]: I'm not getting dna_string[char - length_str: char] ...
0 votes
0 answers
143 views

pset6 I just don't understand what I have to do

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 ...
0 votes
1 answer
108 views

PSET6 DNA Why is my (count consecutive substrings in string) function always returns 0's?

I tried writing different function variations but my count_dna function keeps returning zeroes (despite having consecutive sequences of STRs in the dna sequences)--can anyone please tell me why? Note: ...
1 vote
1 answer
319 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
1 answer
85 views

What does "consecutively" mean in pset6 DNA?

I am working on pset6 DNA and I'm not sure I understand the terms of the problem. The objective is to write a program that matches a DNA sequence to a person in a DNA database based on the largest ...
0 votes
1 answer
120 views

Pset6 - DNA - Strange Error

I'm in the [ Testing ] section and my program works fine with [ small.csv ], but the expected data is not the same as the real data: For example: If I run this: python dna.py databases/large.csv ...
0 votes
0 answers
73 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
1 answer
101 views

DNA Max Sequence Bug | Working on small.csv but not on large.csv

This is the complete code: """ - open csv file and sequence , read contents - for each str, compute longest chain - compare str counts aganist ech row in csv file """...
0 votes
1 answer
173 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
1 answer
114 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 ...
0 votes
1 answer
105 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
1 answer
79 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
1 answer
101 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
1 answer
434 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 ...
1 vote
1 answer
727 views

DNA code doesn't work sometimes

OK, so I`ve got a strange bug in my DNA code. Basically, it works fine, but somehow it gives incorrect output at samples 6, 8, 9, 19. When I looked more carefully through my STR check results, it ...
0 votes
1 answer
123 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 ...