Question
I'm trying to create a python program that reads the contents of two files and creates a two character pair combination that is stored in
I'm trying to create a python program that reads the contents of two files and creates a two character pair combination that is stored in a list. A List of Lists is created of each possible protein combination and the number of occurences is counted. The values in the occurrences List are then displayed as a report and stored in in an output file named analysis.txt.
I have set up my program and have commented out each part of the code, but need help writing the actual code as I don't understand how to make a List of Lists.
Code:
# Define a match() function that accepts two filenames as arguments # and returns a list of combined protein pairs in the DNA chain def match(RightChainfile,LeftChainfile):
# Display the status message: 'Reading and Processing Protein Pairs...' print("Reading and Processing Protein Pairs...") # Open and read the contents of the two files file1=open(RightChainfile,"r") file2=open(LeftChainfile,"r") # Combine the matching values into a list of protein pairs # Close the two files
# Return the list of combined protein pairs
# Define an occur() function that accepts one List as an argument and # and creates a new List containing the number of occurrences of each # pair combination from the List argument def occur():
# Display the status message: 'Counting Occurrences...' print("Counting Occurrences...") # Create a new List of Lists using the protein pair combinations and # the number of times each occurs in the protein pair List
# Return the List of occurences
# Define the main() function def main():
# Display a message describing the purpose of the program print("This program reads the contents of two files containing the left and right chains and creates a two-character pair combination") print("that is stored in a list. A List of Lists is created of each possible protein combination and the number of occurences is counted.") print("The values in the occurrences List are then displayed as a report and stored in in an output file named analysis.txt.") # Prompt the user for two filenames file1=input("Please enter the first file name: ") file2=imput("Please enter the second file name: ") # Call the match() function providing the two filenames as arguments # Assign the List returned by occur() to a variable
# Display the List returned by occur in a table format with two columns reading Pair and Occurences # and a title named Alien Protein Analysis
# Display the message: 'Creating the Output File: analysis.txt' # This file should include the same text as 'Alien Protein Analysis'
# Close the analysis.txt file analysis.close() # Display the message: 'Processing Complete.' print("Proccessing Complete.") # Call the main() function main()
The end result should look something similar to this:
Any help is much appreciated!
Problem Description: You are investigating an alien life form found frozen in the ice of Antarctica. A genetic sample has been isolated and the data from this sample is stored in two (2) files. The structure is very different from the types of life found on earth. Chemical analysis has determined that each compound chain is 1 million DNA "pairs" long. You have two files containing 1 million characters representing the life form's genetic chain separated into the left half (Chain.Left) and right half (Chain.Right). The left half of the chain uses 4 different proteins (designated as c, m, t, or s) while the right half uses only 2 proteins (designated G or v). The compounds that make up each 'strand' or full chain of material are paired using one of 8 combinations: A partial sample of a chain: (Example: not from the actual data) Chain.Left file: tsscmcsts Chain.Right file: VGVVGGvvG DNA sequence after completing a left/right pairing The Assignment Your assignment is to write a Python function that completes the following tasks: Read the contents of the two (2) files containing the left and right halves of the chain Pair the left/right protein values into a two-character pair combination, storing them in a List Create a new List of Lists containing each of the possible protein combinations and the count of the number of occurrences each value Using the values in the occurrences List, display a report and create an output file named analysis.txt containing the results of your analysisStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started