\[ \begin{align}\begin{aligned}\newcommand\blank{~\underline{\hspace{1.2cm}}~}\\% Bold symbols (vectors) \newcommand\bs[1]{\mathbf{#1}}\\% Poor man's siunitx \newcommand\unit[1]{\mathrm{#1}} \newcommand\num[1]{#1} \newcommand\qty[2]{#1~\unit{#2}}\\\newcommand\per{/} \newcommand\squared{{}^2} \newcommand\cubed{{}^3} % % Scale \newcommand\milli{\unit{m}} \newcommand\centi{\unit{c}} \newcommand\kilo{\unit{k}} \newcommand\mega{\unit{M}} % % Percent \newcommand\percent{\unit{\%}} % % Angle \newcommand\radian{\unit{rad}} \newcommand\degree{\unit{{}^\circ}} % % Time \newcommand\second{\unit{s}} \newcommand\s{\second} \newcommand\minute{\unit{min}} \newcommand\hour{\unit{h}} % % Distance \newcommand\meter{\unit{m}} \newcommand\m{\meter} \newcommand\inch{\unit{in}} \newcommand\foot{\unit{ft}} % % Force \newcommand\newton{\unit{N}} \newcommand\kip{\unit{kip}} % kilopound in "freedom" units - edit made by Sri % % Mass \newcommand\gram{\unit{g}} \newcommand\g{\gram} \newcommand\kilogram{\unit{kg}} \newcommand\kg{\kilogram} \newcommand\grain{\unit{grain}} \newcommand\ounce{\unit{oz}} % % Temperature \newcommand\kelvin{\unit{K}} \newcommand\K{\kelvin} \newcommand\celsius{\unit{{}^\circ C}} \newcommand\C{\celsius} \newcommand\fahrenheit{\unit{{}^\circ F}} \newcommand\F{\fahrenheit} % % Area \newcommand\sqft{\unit{sq\,\foot}} % square foot % % Volume \newcommand\liter{\unit{L}} \newcommand\gallon{\unit{gal}} % % Frequency \newcommand\hertz{\unit{Hz}} \newcommand\rpm{\unit{rpm}} % % Voltage \newcommand\volt{\unit{V}} \newcommand\V{\volt} \newcommand\millivolt{\milli\volt} \newcommand\mV{\milli\volt} \newcommand\kilovolt{\kilo\volt} \newcommand\kV{\kilo\volt} % % Current \newcommand\ampere{\unit{A}} \newcommand\A{\ampere} \newcommand\milliampereA{\milli\ampere} \newcommand\mA{\milli\ampere} \newcommand\kiloampereA{\kilo\ampere} \newcommand\kA{\kilo\ampere} % % Resistance \newcommand\ohm{\Omega} \newcommand\milliohm{\milli\ohm} \newcommand\kiloohm{\kilo\ohm} % correct SI spelling \newcommand\kilohm{\kilo\ohm} % "American" spelling used in siunitx \newcommand\megaohm{\mega\ohm} % correct SI spelling \newcommand\megohm{\mega\ohm} % "American" spelling used in siunitx % % Inductance \newcommand\henry{\unit{H}} \newcommand\H{\henry} \newcommand\millihenry{\milli\henry} \newcommand\mH{\milli\henry} % % Power \newcommand\watt{\unit{W}} \newcommand\W{\watt} \newcommand\milliwatt{\milli\watt} \newcommand\mW{\milli\watt} \newcommand\kilowatt{\kilo\watt} \newcommand\kW{\kilo\watt} % % Energy \newcommand\joule{\unit{J}} \newcommand\J{\joule} % % Composite units % % Torque \newcommand\ozin{\unit{\ounce}\,\unit{in}} \newcommand\newtonmeter{\unit{\newton\,\meter}} % % Pressure \newcommand\psf{\unit{psf}} % pounds per square foot \newcommand\pcf{\unit{pcf}} % pounds per cubic foot \newcommand\pascal{\unit{Pa}} \newcommand\Pa{\pascal} \newcommand\ksi{\unit{ksi}} % kilopound per square inch \newcommand\bar{\unit{bar}} \end{aligned}\end{align} \]

Oct 24, 2024 | 475 words | 5 min read

7.3.1. Task 1#

Learning Objectives#

Predict the output of a complete for and while loop in Python using flowcharts; Use loops to conduct repetitive operations to perform numerical operations in Python; Create, manipulate, and read from arrays, lists, and dictionaries in Python; Manipulate and extract information from lists, arrays, and dictionaries in Python; Use loops to compare and evaluate associated elements in data sets in Python.

Introduction#

Bioinformatics is an interdisciplinary field that develops and applies computational methods to analyze large collections of biological data, such as genetic sequences, protein samples, and cell populations.

In this assignment, you are asked to create a Python program that maps different chromosome combinations to their corresponding phenotypes, a key concept in genetics. The program takes user input and delivers output based on the genetic concept of dominant and recessive traits, which is a common task in bioinformatics. These kinds of programs are essential in analyzing and interpreting biological data, especially genetic data, which is a major part of the bioinformatics field.

Chromosomes carry the genetic instructions used in the growth, development, functioning, and reproduction of all living organisms. Different combinations of chromosomes can lead to different observable physical attributes, known as phenotypes. In this assignment, you will write a Python script that maps the chromosome combinations to their respective phenotypes using the provided flowchart.

Task Instructions#

../../../../../_images/py3_ind1.png

Review the flowchart provided above.

Translate the flowchart into Python code using the ENGR133_Python_Template.py. Your script should include the following:

a. Import a list of features available for chromosome-to-phenotype mapping using the list_of_features.csv.

b. Print the available features that the user can select.

c. Prompt the user to select a feature they are interested in. If the user does not enter a valid feature, print an error message.

d. After the user has selected a feature, print the genotypes for the feature (e.g. BB, Bb, or bb).

e. Prompt the user to select one of the genotypes. If the user does not enter a valid feature, print an error message.

f. Once the user has input the genotype, print the corresponding physical attribute. For example, if the feature is eyebrows and the chromosome type is BB or Bb, output “Thick Eyebrows”. If chromosome type is bb, output “Thin Eyebrows”.

g. After the physical attribute is displayed, ask the user if they want to run the program again. End or continue the program according to the input from the user.

Save your file in a Python file called: py3_ind_1_username.py

Sample Output#

Use the values in Table 7.9 below to test your program.

Table 7.9 Test Cases#

Case

feature

genotype

1

Chin

CC

2

Head

CC

Ensure your program’s output matches the provided samples exactly. This includes all characters, white space, and punctuation. In the samples, user input is highlighted like this for clarity, but your program should not highlight user input in this way.

Case 1 Sample Output

$ python3 py3_ind_1_username.py AVAILABLE FEATURES: Head Chin Neck Ears Ear lobe Nose length Nose width Mouth Lips Teeth Eyes position Eye color Eyebrows Glasses Freckles Hair color Hair type Please select a feature: Chin POSSIBLE GENOTYPES: CC Cc cc Please input the genotype: CC This corresponds to the physical attribute: Square Chin Would you like to run again? (y or n): n

Case 2 Sample Output

$ python3 py3_ind_1_username.py AVAILABLE FEATURES: Head Chin Neck Ears Ear lobe Nose length Nose width Mouth Lips Teeth Eyes position Eye color Eyebrows Glasses Freckles Hair color Hair type Please select a feature: Head POSSIBLE GENOTYPES: SS Ss ss Please input the genotype: CC Invalid input. Would you like to run again? (y or n): n