Write a Python function makeDict() that takes a filename as a parameter. The file contains DNA sequences in Fasta format,
for example:
>human
ATACA
>mouse
AAAAAACT
The function returns a dictionary of key:value pairs, where the key is the taxon name and the valus is the total number of 'A' and 'T' occurrences. For example, for if the file contains the data from the example above the function should return: {'human':4,'mouse':7}

OUTPUT :

CODE:
def makeDict(filename):
#Open file
f = open(filename)
#Read all lines
lines = f.readlines()
#Initiaize dictionary for ans
ans = {}
for i in range(0,len(lines),2):
#Read taxon and sequence
taxon = lines[i].strip()[1:]
sequence = lines[i+1].strip()
#A, T counter
AT = 0
#Loop through sequence to find A, T Count
for s in sequence:
if s in 'AT':
AT = AT+1
ans[taxon] = AT
return ans
seq.txt:
>human
ATACA
>mouse
AAAAAACT
Write a Python function makeDict() that takes a filename as a parameter. The file contains DNA...
PYTHON: Write a function that takes, as an argument, the name of a file, fileName, and an integer n between -750 and 750 (inclusive). Your program should verify that n is an integer in the correct range. If it is not, it should return the string “Your integer is out of range.” If it is in the correct range, your program should open (and read through) the file specified, and return the number of values in the file that are...
Write a Python program that converts an input file in FASTA format, called "fasta.txt", to an output file in PHYLIP format called "phylip.txt". For example, if the input file contains: >human ACCGTTATAC CGATCTCGCA >chimp ACGGTTATAC CGTACGATCG >monkey ACCTCTATAC CGATCGATCC >gorilla ATCTATATAC CGATCGATCG Then the output file should be human ACCGTTATACCGATCTCGCA chimp ACGGTTATACCGTACGATCG monkey ACCTCTATACCGATCGATCC gorilla ATCTATATACCGATCGATCG FASTA format has a description (indicated with a '>') followed by 1 or more lines of a DNA sequence. PHYLIP format has a description...
Write a function named "loadStateDict(filename) that takes a filename and returns a dictionary of 2-character state codes and state names. The file has four columns and they are separated by commas. The first column is the state full name and the second column is the state code. You don't have to worry about column 3 & 4. You should eliminate any row that is without a state code. Save the two columns into a dictionary with key = state code...
Help me with this Python Question a. build_word_dictionary (filename) – This builds a word dictionary indexed by words from the file who’s filename is provided as an argument. It uses the words as keys and the count of occurrences as values. It returns the dictionary it constructed. It can use the ‘tokenize()’ function that is provided in the lecture slides. b. inverse_dict(dict) – This method takes a dictionary (generated by build_word_dictionary() and inverts it (as was done with students and...
Python 3 Write a function named inverse that takes a single parameter, a dictionary. In this dictionary each key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course. For example, the following...
python/idle 1. Write a program that counts the number of A’s in a DNA sequence. The input is one sequence in FASTA format in a file called ‘dna.txt’. For example, if the file contains: >human ACCGT then the output of the program should be 1. Your program should work for any sequence and not just the one in the example.
average_value_in_file / Python 3.x: Your assistance is appreciated, thank you! Write a function named average_value_in_file that accepts a file name as a parameter and reads that file, assumed to be full of numbers, and returns the average (mean) of the numbers in that file. The parameter, filename, gives the name of a file that contains a list of numbers, one per line. You may assume that the file exists and follows the proper format. For example, if a file named...
python
Write the function getSpamLines(filename) that read the filename text file and look for lines of the form 'SPAM-Confidence: float number'. When you encounter a line that starts with "SPAM-Confidence:" extract the floating-point number on the line. The function returns the count of the lines where the confidence value is greater than 0.8. For example, if 'spam.txt' contains the following lines along with normal text getSpamLines('spam.txt') returns 2. SPAM-Confidence: 0.8945 Mary had a little lamb. SPAM-Confidence: 0.8275 SPAM-Confidence: 0.7507 The...
5. Write a Python function called readlinesmton that accepts the name of the file (i.e. filename), starting line number i.e. m) and ending line number (i.e. n) as a parameter. The function then returns the contents from line number m to n (m <n). If m < 1 then start from line 1. Similarly, if n > number of lines the file, then stop at the last line in the file. Sample Input: readlinesmton("data.txt",5,7) Sample Input: readlinesmton("data.txt", 0,10)
Write a function that takes, as an argument, the name of a file, fileName . Your program should open (and read through) the file specified, and return the maximum value in the file. Name this function maxValueInFile(fileName). def openFile(): # Prompt for the file name filename =input("Enter a file name: " ) # Open the file for reading file = open(filename) # Prompt for the target value target =input("Enter a threshold value: ") # Initialize the counter counter = 0...