Git Product home page Git Product logo

cs50_dna's Introduction

Hi My name is Vincent Taneri

Welcome to my Github Profile

๐Ÿ’ซ About Me

  • ๐ŸŒย  I'm based in Taiwan
  • ๐Ÿ› ย  I love building cool stuffs
  • โœ๏ธย  I write articles on my blog sometimes
  • โœ‰๏ธย  You can contact me at [email protected]
  • ๐Ÿง ย  I love learning new stuffs
  • ๐Ÿ“š I spend most of my free time reading
  • ๐Ÿ“บ Or watch anime
  • ๐ŸŽฎ Or gaming

๐ŸŒ Socials

LinkedIn Twitter

๐Ÿ’ป Tech Stack

Go JavaScript TypeScript Python Java HTML5 CSS3 Chakra Express.js Next JS NodeJS React Native React TailwindCSS

๐Ÿ“Š GitHub Stats



๐Ÿฅฐ Moe Dose

:tanerijun

โœ๏ธ Random Quote For You

๐Ÿค“ Books I'm Reading

โœ๏ธ My Recent Blog Posts

๐Ÿ’ฐ Support Me

BuyMeACoffee

cs50_dna's People

Contributors

tanerijun avatar

Stargazers

 avatar

Watchers

 avatar

cs50_dna's Issues

CS50 DNA help Week6

Can someone please help me with my code for Week 6 in CS50. It is not working

import csv
import sys

def main():

# TODO: Check for command-line usage
if len(sys.argv) != 3:
    sys.exit("Usage: python dna.py data.csv sequence.txt")


# TODO: Read database file into a variable
database = []
with open(sys.argv[1], "r") as file:
    reader = csv.DictReader(file)
    for name in reader:
        name["AGATC"] = int(name["AGATC"])
        name["TTTTTTCT"] = int(name["TTTTTTCT"])
        name["AATG"] = int(name["AATG"])
        name["TCTAG"] = int(name["TCTAG"])
        name["TATC"] = int(name["TATC"])
        name["GATA"] = int(name["GATA"])
        name["GAAA"] = int(name["GAAA"])
        name["TCTG"] = int(name["TCTG"])

        database.append(name)

# TODO: Read DNA sequence file into a variable
dna = []
with open(sys.argv[2], "r") as file:
    dna = file.read()

# TODO: Find longest match of each STR in DNA sequence
AGATC = int(longest_match(dna, "AGATC"))
TTTTTTCT = int(longest_match(dna, "TTTTTTCT"))
AATG = int(longest_match(dna, "AATG"))
TCTAG = int(longest_match(dna, "TCTAG"))
TATC = int(longest_match(dna, "TATC"))
GATA = int(longest_match(dna, "GATA"))
GAAA = int(longest_match(dna, "GAAA"))
TCTG = int(longest_match(dna, "TCTG"))

# TODO: Check database for matching profiles
for row in database:
    if TCTG and TTTTTTCT and AATG and TCTAG and TATC and GATA and GAAA and AGATC in row:
        print(row["name"])
        return
    else:
        continue

def longest_match(sequence, subsequence):
"""Returns length of longest run of subsequence in sequence."""

# Initialize variables
longest_run = 0
subsequence_length = len(subsequence)
sequence_length = len(sequence)

# Check each character in sequence for most consecutive runs of subsequence
for i in range(sequence_length):

    # Initialize count of consecutive runs
    count = 0

    # Check for a subsequence match in a "substring" (a subset of characters) within sequence
    # If a match, move substring to next potential match in sequence
    # Continue moving substring and checking for matches until out of consecutive matches
    while True:

        # Adjust substring start and end
        start = i + count * subsequence_length
        end = start + subsequence_length

        # If there is a match in the substring
        if sequence[start:end] == subsequence:
            count += 1

        # If there is no match in the substring
        else:
            break

    # Update most consecutive matches found
    longest_run = max(longest_run, count)

# After checking for runs at each character in seqeuence, return longest run found
return longest_run

main()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.