Appendix A — Stop & Think Answers —

Author

Ryan M. Moore, PhD

Published

April 24, 2025

Modified

April 28, 2025

: When Python tries to evaluate the name gene and doesn’t find it in any scope, it raises a NameError, which matches the exception type specified in the except clause. This causes a message with the error details to be printed to the console.

: FileNotFoundError

: We could check if the expression value is “na” before trying to convert it, or use a try/except block to catch the ValueError and set a default value (like None, 1, 0, or NaN).

: When analyzing sequencing datasets, one error might trigger others in a cascade. For example, a file reading error might lead to missing data, which then causes calculation errors. This chain makes it harder to find the root cause of the error.

: Specific exceptions might include: FileNotFoundError, PermissionError, IsADirectoryError. All of these could be caught by OSError, which is the parent class for file-related errors.

: The finally clause is useful when working with resources that need to be released regardless of success or failure, such as closing file handles or database connections.

: Possible custom exceptions: InvalidSequenceError, AlignmentFailedError, LowCoverageError, DifferentialExpressionError, etc.