Jump to content

Bioinformatics/base count: Difference between revisions

→‎{{header|REXX}}: Refurbished (better variable names and no Upper instruction)
(add RPL)
(→‎{{header|REXX}}: Refurbished (better variable names and no Upper instruction))
Line 2,940:
=={{header|REXX}}==
A little extra boilerplate was added to verify correct coding of the bases in a DNA string and the alignment of the (totals) numbers.
<syntaxhighlight lang="rexx">/*REXX program finds the number of each base in a DNA string (along with a total). */
@.=/* 0 (along with a total). /*initialize the count for all bases. */
parseParse argArg dna .
if dna=='' | dna=="," then dna= 'cgtaaaaaattacaacgtcctttggctatctcttaaactcctgctaaatg' ,
If dna==''|dna==',' Then
'ctcgtgctttccaattatgtaagcgttccgagacggggtggtcgattctg' ,
if dna=='' | dna=="," then dna= 'cgtaaaaaattacaacgtcctttggctatctcttaaactcctgctaaatg' ,
'aggacaaaggtcaagatggagcgcatcgaacgcaataaggatcatttgat' ,
'ctcgtgctttccaattatgtaagcgttccgagacggggtggtcgattctg' ,
'gggacgtttcgtcgacaaagtcttgtttcgagagtaacggctaccgtctt' ,
'aggacaaaggtcaagatggagcgcatcgaacgcaataaggatcatttgat' ,
'cgattctgcttataacactatgttcttatgaaatggatgttctgagttgg' ,
'gggacgtttcgtcgacaaagtcttgtttcgagagtaacggctaccgtctt' ,
'tcagtcccaatgtgcggggtttcttttagtacgtcgggagtggtattata' ,
'cgattctgcttataacactatgttcttatgaaatggatgttctgagttgg' ,
'tttaatttttctatatagcgatctgtatttaagcaattcatttaggttat' ,
'tcagtcccaatgtgcggggtttcttttagtacgtcgggagtggtattata' ,
'cgccgcgatgctcggttcggaccgccaagcatctggctccactgctagtg' ,
'tttaatttttctatatagcgatctgtatttaagcaattcatttaggttat' ,
'tcctaaatttgaatggcaaacacaaataagatttagcaattcgtgtagac' ,
'cgccgcgatgctcggttcggaccgccaagcatctggctccactgctagtg' ,
'gaccggggacttgcatgatgggagcagctttgttaaactacgaacgtaat'
'tcctaaatttgaatggcaaacacaaataagatttagcaattcgtgtagac' ,
dna= space(dna, 0); upper dna /*elide blanks from DNA; uppercase it. */
'gaccggggacttgcatgatgggagcagctttgttaaactacgaacgtaat'
say '────────length of the DNA string: ' length(dna)
dna= translate(space(dna, 0); upper dna ) /* elide blanks from DNA; uppercase it. uppercas*/
@.= 0 /*initialize the count for all bases. */
saySay '────────length--------length of the DNA string: ' length(dna)
w= 1 /*the maximum width of a base count. */
$count.= 0 /*a placeholder forinitialize the namescount offor all bases.*/
w=1 do j=1 for length(dna) /*traipse through the maximum DNA width string.of a base count */
names='' _= substr(dna, j, 1) /* list of all names /*obtain a base name from the DNA str. */
Do j=1 To if poslength(_, $dna)==0 then $= $ || _ /*if nottraipse through foundthe before, addDNA it tostring list. */
@._name= @._ + substr(dna,j,1 ) /*bump theobtain count of thisa base. name from the DNA */
If pos(name,names)==0 Then
w= max(w, length(@._) ) /*compute the maximum width number. */
names=names||name /* if not found, add it to the list */
end /*j*/
count.name=count.name+1 /* bump the count of this base. */
say
w= max(w, length(@count._name) ) /* compute the maximum width number. width */
do k=0 for 255; z= d2c(k) /*traipse through all possibilities. */
End
if pos(z, $)==0 then iterate /*Was this base found? No, then skip. */
Say
say ' base ' z " has a basecount of: " right(@.z, w)
Do k=0 To 255
@.tot= @.tot + @.z /*add to a grand total to verify count.*/
end /*z=d2c(k*/ ) /*stick a fork in it, traipse we'rethrough all done.possibilities */
If pos(z,names)>0 Then Do
say
say '────────total for all basecounts:Say ' base ' z ' has a basecount of: ' right(@count.totz, w+1)</syntaxhighlight>
@count.tot= @count.tot + @count.z /* add to a grand total to verify count. */
End
End
Say
Say '--------total for all basecounts:' right(count.tot,w+1)
</syntaxhighlight>
{{out|output|text=&nbsp; when using the default input:}}
<pre>
Line 2,982 ⟶ 2,988:
────────total for all basecounts: 500
</pre>
 
=={{header|Ring}}==
<syntaxhighlight lang="ring">
2,295

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.