Some days ago I experimented a bit to colorize a random DNA sequence given an alphabet and the desired sequence size, with a little help of BioSmalltalk. This is what I've got:
1 2 3 4 5 6 7 8 | | text attributes | text := ((BioSequence forAlphabet: BioDNAAlphabet) randomLength: 6000 ) sequence asText. attributes := Array new: text size. 1 to: text size do: [ : index | attributes at: index put: { (TextColor color: (BioDNAAlphabet colorMap at: (text at: index))) } ]. text runs: (RunArray newFrom: attributes). text. |
I built a color map for every nucleotide, based on the alphabet size. This is because in biological sequences (proteins, DNA, RNA) you have a different set of letters.
I should say I don't like the final result. Specially the lack of column alignment:

This seems to persist even trying other attributes
1 2 3 4 5 6 7 8 9 | | text attributes | text := ((BioSequence forAlphabet: BioDNAAlphabet) randomLength: 6000 ) sequence asText. attributes := Array new: text size. 1 to: text size do: [ : index | attributes at: index put: { (TextColor color: (BioDNAAlphabet colorMap at: (text at: index))) . (TextKern kern: 4 ) } ]. text runs: (RunArray newFrom: attributes). text. |
Maybe efforts in Bloc would make it easier for aligning text.
0 comentarios:
Publicar un comentario