Questions tagged [pset6]

The problem set for Week 7

Filter by
Sorted by
Tagged with
0
votes
0answers
11 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
0answers
11 views

Cs50 pset6 readability.py math

I'm trying to run this code and everything complies but when I enter the text in it is giving me the wrong grade level. I believe it might be something in the math, but am still unsure. Here's my code:...
0
votes
1answer
30 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
0answers
27 views

Almost Done… But substrings

// Returns true if word is in dictionary else false bool check(const char *word) { //Variables bool looping = true; int hashWord = hash(word); //Create a new pointers node *head = table[hashWord]; ...
0
votes
1answer
20 views

PSET6 Credit - checksum not giving the correct number

list1 = list(input("Number: ").strip()) even_count, odd_count, count = 0, 0, 0 # if the length is even if len(list1)%2 == 0: # iterating each number in list for num in list1: ...
1
vote
1answer
23 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
1answer
23 views

Struggling to align pyramid and check for extra spaces at the end of each line in pset6 mario.py less

I'm struggling to meet these specifications - "Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line." ...
0
votes
0answers
20 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
68 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
3answers
39 views

PSET6 Mario Python

I have been experiementing with this code for a couple hours and have come across an issue with each implementation. I can no longer put in any time at the moment so I figured I would go ahead and ask....
0
votes
0answers
62 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
14 views

my count is not working for csv.large [closed]

for j in range(len(STRs)): inilist = [i for i in range(0, len(sequence)) if sequence[i:].startswith(STRs[j])] for k in range(len(inilist)): k += 1 ...
0
votes
0answers
53 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
44 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
74 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
0answers
29 views

PSET 6 - credit, pythonic or not?

I didn't do credit for problem set 1 (I chose less comfortable) so I don't know what the C implementation was. I was wondering if you guys think this is too C-like or if it's okay for python code. Any ...
0
votes
0answers
29 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
36 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
92 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
120 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
89 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
196 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
126 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
63 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
49 views

What are the requirements for Week 6 Mario (more)? My code works but the grade book shows only 96% completeness

I tried two different variations but both reach 96% completeness code 1: from cs50 import get_int while True: height = get_int("Height: ") if height < 9 and height > 0: break ...
0
votes
1answer
98 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
65 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
48 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
62 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
33 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
42 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
151 views

Pset 6 Readability returns higher than expected grade

My code is right below I am unable to find the issue because my C code for readability was basically the same(except syntax and formatting of course!) and it was working perfectly. This Python code is ...
0
votes
1answer
86 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
37 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
171 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
1answer
46 views

pset6/less/Mario passing all checks, but score at 90%

My code is getting 9/9 on the check. Visually it seems fine as well. There doesn't seem to be any preceding or trailing empty spaces. The score, however, is 90%. Any help in identifying the mistake ...
0
votes
1answer
30 views

I keep on getting index out of range?

from cs50 import get_string s = get_string("Text: ") letter = 0 i = 0 word = 1 sent = 0 while s[i] != None: if s[i] == ' ': word = word + 1 i = i + 1 elif (s[i].isalpha()): ...
0
votes
0answers
78 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
88 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 ...
0
votes
1answer
123 views

PSET6 DNA - I passed every test it wanted me to do, but I got 42% after submitting?

I completed the DNA problem on pset6. There is a series of tests you need to enter into the command line before you submit, and I did all of them and passed every single one (as shown below). However, ...
0
votes
0answers
20 views

checking column for value results in wrong column being searched

I am trying to obtain obtain a column from a dataframe. I used panda to read the file. df = pd.read_csv(sys.argv[1]) When I am trying to access the df by a specific STR, the STR is placed as the ...
0
votes
1answer
70 views

MY code works with a hardcoded string, but not a string object

I'm working on pset6 2020 dna. I'm having trouble inputting the sequence file to be compared into my search function. If I just open the file and copy paste the sequence into the code as a string, it ...
0
votes
0answers
120 views

PSET6 DNA - Counting some of the STRs incorrectly

I've spent many days working on DNA and on the verge of giving up. I was hoping to get some help with my code. It finds some of the STRs correctly but miscounts the other STRs. I'm trying to ...
0
votes
1answer
70 views

pset6 mario/more - output is seemingly correct, however failing tests

I've just finished mario/more in pset6, however, it does not pass the tests. The actual and expected outputs are identical, so is the expected string. The pyramid also looks identical to the c ...
0
votes
0answers
18 views

How to fix this? I can't use debug50 in python

This is the output when I use debug50 in phyton Traceback (most recent call last): File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/...
0
votes
0answers
106 views

Problems with PSET6 – DNA

I don't understand why my code below isn't working. Instead of printing out the name of the person, it simply prints out No match found every time, even when there is supposed to be a match. If anyone ...
0
votes
1answer
77 views

Python pset6 - should a file be closed at the end of the program or in the middle?

I'm slowly working through DNA on pset6 and I am running into some issues with the opening/closing of CSVs. I open the CSV using with open(database, "r") as csv_file: csv_reader = csv.DictReader(...
0
votes
1answer
231 views

Kind of lost in pset6 dna, How to compare the max number of occurrences of the STR's with the database?

I'm kind of lost I don't know how I can compare the max number of occurrences with the database. My program here can get the max number of it stored in a list called counts to get it I used a function ...
0
votes
1answer
242 views

Difficulty comparing sequence and individual in PSET6 DNA

I have nearly completed DNA in Pset6 of CS50 but I am having difficulty on the last section. I have managed to populate each of the max_AGATC, max_TTTTTTCT, max_AATG etc. with the correct values from ...
0
votes
1answer
57 views

pset 6 mario, I'm getting wrong ouput

I'm getting an extra new line just after getting input. Help me fix it while True: n = cs50.get_int("Height: ") if n > 0 and n < 9: break for i in range(n + 1): if n == 0: ...

1
2 3 4 5
17