Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
comik/getColored.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
45 lines (41 sloc)
1.25 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [colored_string] = getColored(given_string, oligoLen) | |
% GETCOLORED | |
% Colors the given string (DNA motif) using the IUPAC color scheme for the nucleotides A, C, G, T. | |
% | |
% INPUT PARAMS | |
% Param 'given_string' | |
% The DNA oligomer | |
% | |
% Param 'oligoLen' | |
% Length of the oligomer | |
% | |
% OUTPUT PARAMS | |
% Param 'colored_string' | |
% String with each DNA sequence character appropriately colored according to the IUPAC scheme | |
% | |
% ADDITIONAL NOTES | |
% | |
% | |
% Author: snikumbh@mpi-inf.mpg.de | |
given_string = char(given_string); | |
alphabet = upper('acgt'); | |
colored_string = []; | |
for i=1:size(given_string, 2) | |
% i iterates over the number of characters in the string | |
if isscalar(given_string(1,i)) | |
if oligoLen~= 0 && i == oligoLen+1 | |
colored_string = strcat(colored_string, '\color{black}|'); | |
end | |
switch(given_string(1,i)) | |
case 'A' | |
colored_string = [colored_string strcat('\color[rgb]{0 0.5 0}', given_string(1,i))]; | |
case 'C' | |
colored_string = [colored_string strcat('\color{blue}', given_string(1,i))]; | |
case 'G' | |
colored_string = [colored_string strcat('\color{orange}', given_string(1,i))]; | |
case 'T' | |
colored_string = [colored_string strcat('\color{red}', given_string(1,i))]; | |
end | |
end | |
end | |
end |