- Python basics
- Demonstration of converting previous assignments from C to Python
- Features that C does not have
I broke down this programme into a few small functions, dealing with the DNA database, the input DNA sequences, and the computation of DNA results respectively.
At the beginning of this programme, it checks the number of command-line arguments first. If the user does not pass 3 arguments on the command line, this programme exits.
If 3 command-line arguments are passed, this programme reads the database by calling function
read_db(). The second command-line argument, supposed to be the file name of a database, is passed to this function.
read_db() reads the database and save all data to a global variable
Then, it gets a list of DNA result by calling function
find_dna(). The third command-line argument, supposed to be the file name of a DNA sequence, is passed to the function along with a list of STRs.
With the DNA result, it identifies if any value from DNA database matches the DNA result.
read_db() takes an argument. The filename of the database file got back from the command line should be passed into this function.
After opening the CSV file, it reads data from it into a global variable
db_dict is a dictionary containing people’s name as keys and their corresponding DNA data list as values except for the first key-value pair, which are column titles of the raw data.