From Project ROSALIND: Introduction to Random Strings http://rosalind.info/problems/prob/ Version History 2020-04-14 — David M. Ng — Initial version.
The code is decomposed into three main parts. Main program (i.e., event handler for [when green flag clicked]) — get user input, then * ParseGCcontentLine * ComputeLogProbabilities * FormatLogProbOutput ParseGCcontentLine — The GC content is provided as a single line of space-separated numbers. This custom block parses the line and stores each number as a separate item in the GCcontent list. The code works as follows: * Assume a number starts a position 1. * Numbers are terminated by a single space character, or by the end of the line. * There are two separate pieces of code for each of the number terminator cases. Their indexing is slightly different; beware of off-by-one problems. ComputeLogProbabilities — To multiply probabilities you add their logs (because logs are exponents). FormatLogProbOutput — The log probabilities were stored in a list. This custom block formats the log probabilities into a single line (because that is the specified output format for this problem). Then this line (built as a scalar) is placed into the first (and only) entry of a list (because Scratch does not support copy from a scalar variable or from “say” block output, but you can copy from a list item).