Jump to content

Bioinformatics/base count: Difference between revisions

m
→‎{{header|REXX}}: added whitespace.
m (→‎{{header|REXX}}: (internal only) changed the DNA sequence to lowercase; output DNA sequence is still uppercase.)
m (→‎{{header|REXX}}: added whitespace.)
Line 969:
dna= space(dna, 0); upper dna /*elide blanks from DNA; uppercase it. */
say '────────length of the DNA string: ' length(dna)
@.=0 0 /*initialize the count for all bases. */
w= 1 /*the maximum width of a base count. */
$= /*a placeholder for the names of bases.*/
do j=1 for length(dna) /*traipse through the DNA string. */
_= substr(dna, j, 1) /*obtain a base name from the DNA str. */
if pos(_, $)==0 then $= $ || _ _ /*if not found before, add it to list. */
@._= @._ + 1 /*bump the count of this base. */
w= max(w, length(@._) ) /*compute the maximum width number. */
Line 983:
say ' base ' z " has a basecount of: " right(@.z, w)
@.tot= @.tot + @.z /*add to a grand total to verify count.*/
say end /*k*/ /*stick a fork in it, we're all done. */
end /*k*/
say
say /*stick a fork in it, we're all done. */
say '────────total for all basecounts:' right(@.tot, w+1)</lang>
{{out|output|text=&nbsp; when using the default input:}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.