Data Update
This commit is contained in:
parent
015c2add84
commit
e50b5c3114
206 changed files with 6337 additions and 523 deletions
|
|
@ -1,13 +1,13 @@
|
|||
fun printSequence(sequence: String, width: Int = 50) {
|
||||
fun <K, V> printWithLabel(k: K, v: V) {
|
||||
val label = k.toString().padStart(5)
|
||||
println("$label: $v")
|
||||
}
|
||||
|
||||
fun printWithLabel(label: Any, data: Any) =
|
||||
label.toString().padStart(5).also { println("$it: $data") }
|
||||
|
||||
println("SEQUENCE:")
|
||||
sequence.chunked(width).withIndex().forEach { (i, line) ->
|
||||
printWithLabel(i*width + line.length, line)
|
||||
sequence.chunked(width).forEachIndexed() { i, chunk ->
|
||||
printWithLabel(i * width + chunk.length, chunk)
|
||||
}
|
||||
|
||||
println("BASE:")
|
||||
sequence.groupingBy { it }.eachCount().forEach { (k, v) ->
|
||||
printWithLabel(k, v)
|
||||
|
|
@ -17,6 +17,4 @@ fun printSequence(sequence: String, width: Int = 50) {
|
|||
|
||||
const val BASE_SEQUENCE = "CGTAAAAAATTACAACGTCCTTTGGCTATCTCTTAAACTCCTGCTAAATGCTCGTGCTTTCCAATTATGTAAGCGTTCCGAGACGGGGTGGTCGATTCTGAGGACAAAGGTCAAGATGGAGCGCATCGAACGCAATAAGGATCATTTGATGGGACGTTTCGTCGACAAAGTCTTGTTTCGAGAGTAACGGCTACCGTCTTCGATTCTGCTTATAACACTATGTTCTTATGAAATGGATGTTCTGAGTTGGTCAGTCCCAATGTGCGGGGTTTCTTTTAGTACGTCGGGAGTGGTATTATATTTAATTTTTCTATATAGCGATCTGTATTTAAGCAATTCATTTAGGTTATCGCCGCGATGCTCGGTTCGGACCGCCAAGCATCTGGCTCCACTGCTAGTGTCCTAAATTTGAATGGCAAACACAAATAAGATTTAGCAATTCGTGTAGACGACCGGGGACTTGCATGATGGGAGCAGCTTTGTTAAACTACGAACGTAAT"
|
||||
|
||||
fun main() {
|
||||
printSequence(BASE_SEQUENCE)
|
||||
}
|
||||
fun main() = printSequence(BASE_SEQUENCE)
|
||||
|
|
|
|||
|
|
@ -1,31 +1,36 @@
|
|||
/*REXX program finds the number of each base in a DNA string (along with a total). */
|
||||
parse arg dna .
|
||||
if dna=='' | dna=="," then dna= 'cgtaaaaaattacaacgtcctttggctatctcttaaactcctgctaaatg' ,
|
||||
'ctcgtgctttccaattatgtaagcgttccgagacggggtggtcgattctg' ,
|
||||
'aggacaaaggtcaagatggagcgcatcgaacgcaataaggatcatttgat' ,
|
||||
'gggacgtttcgtcgacaaagtcttgtttcgagagtaacggctaccgtctt' ,
|
||||
'cgattctgcttataacactatgttcttatgaaatggatgttctgagttgg' ,
|
||||
'tcagtcccaatgtgcggggtttcttttagtacgtcgggagtggtattata' ,
|
||||
'tttaatttttctatatagcgatctgtatttaagcaattcatttaggttat' ,
|
||||
'cgccgcgatgctcggttcggaccgccaagcatctggctccactgctagtg' ,
|
||||
'tcctaaatttgaatggcaaacacaaataagatttagcaattcgtgtagac' ,
|
||||
'gaccggggacttgcatgatgggagcagctttgttaaactacgaacgtaat'
|
||||
dna= space(dna, 0); upper dna /*elide blanks from DNA; uppercase it. */
|
||||
say '────────length of the DNA string: ' length(dna)
|
||||
@.= 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. */
|
||||
end /*j*/
|
||||
say
|
||||
do k=0 for 255; z= d2c(k) /*traipse through all possibilities. */
|
||||
if pos(z, $)==0 then iterate /*Was this base found? No, then skip. */
|
||||
say ' base ' z " has a basecount of: " right(@.z, w)
|
||||
@.tot= @.tot + @.z /*add to a grand total to verify count.*/
|
||||
end /*k*/ /*stick a fork in it, we're all done. */
|
||||
say
|
||||
say '────────total for all basecounts:' right(@.tot, w+1)
|
||||
/*REXX program finds the number of each base in a DNA string */
|
||||
/* (along with a total). */
|
||||
Parse Arg dna .
|
||||
If dna==''|dna==',' Then
|
||||
dna='cgtaaaaaattacaacgtcctttggctatctcttaaactcctgctaaatg',
|
||||
'ctcgtgctttccaattatgtaagcgttccgagacggggtggtcgattctg',
|
||||
'aggacaaaggtcaagatggagcgcatcgaacgcaataaggatcatttgat',
|
||||
'gggacgtttcgtcgacaaagtcttgtttcgagagtaacggctaccgtctt',
|
||||
'cgattctgcttataacactatgttcttatgaaatggatgttctgagttgg',
|
||||
'tcagtcccaatgtgcggggtttcttttagtacgtcgggagtggtattata',
|
||||
'tttaatttttctatatagcgatctgtatttaagcaattcatttaggttat',
|
||||
'cgccgcgatgctcggttcggaccgccaagcatctggctccactgctagtg',
|
||||
'tcctaaatttgaatggcaaacacaaataagatttagcaattcgtgtagac',
|
||||
'gaccggggacttgcatgatgggagcagctttgttaaactacgaacgtaat'
|
||||
dna=translate(space(dna,0)) /* elide blanks from DNA; uppercas*/
|
||||
Say '--------length of the DNA string: ' length(dna)
|
||||
count.=0 /* initialize the count for all bases*/
|
||||
w=1 /* the maximum width of a base count */
|
||||
names='' /* list of all names */
|
||||
Do j=1 To length(dna) /* traipse through the DNA string */
|
||||
name=substr(dna,j,1) /* obtain a base name from the DNA */
|
||||
If pos(name,names)==0 Then
|
||||
names=names||name /* if not found, add it to the list */
|
||||
count.name=count.name+1 /* bump the count of this base. */
|
||||
w=max(w,length(count.name)) /* compute the maximum number width */
|
||||
End
|
||||
Say
|
||||
Do k=0 To 255
|
||||
z=d2c(k) /* traipse through all possibilities */
|
||||
If pos(z,names)>0 Then Do
|
||||
Say ' base ' z ' has a basecount of: ' right(count.z,w)
|
||||
count.tot=count.tot+count.z /* add to a grand total to verify */
|
||||
End
|
||||
End
|
||||
Say
|
||||
Say '--------total for all basecounts:' right(count.tot,w+1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue