Visualize a string/sequence, emphasizing certain substrings
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I need to visualize a sequence, with the ability to emphasize certain segments.
For example, take this sequence seq
:
seq = -----------------DTLCIGYHANNSTDTVDTVLEKNVTVTHSVNLLEDKHNGKLCK
LRGVAPLHLGKCNIAGWILGNPECESLSTASSWSYIVETPSSDNGTCYPGDFIDYEELREQLSSVSSFER
FEIFPKTSSWPNHDSNKGVTAACPHAGAKSFYKNLIWLVKKGNSYPKLSKSYINDKGKEVLVLWGIHHPS
TSADQQSLYQNADTYVFVGSSRYSKKFKPEIAIRPKVRDQEGRMNYYWTLVEPGDKITFEATGNLVVPRY
AFAMERNAGSGIIISDTPVHDCNTTCQTPKGAINTSLPFQNIHPITIGKCPKYVKSTKLRLATGLRNIPS
G----LFGAIAGFIEGGWTGMVDGWYGYHHQNEQGSGYAADLKSTQNAIDEITNKVNSVIEKMNTQFTAV
GKEFNHLEKRIENLNKKVDDGFLDIWTYNAELLVLLENERTLDYHDSNVKNLYEKVRSQLKNNAKEIGNG
CFEFYHKCDNTCMESVKNGTYDYPKYSEEAKLNREEIDS-------------------------------
--------------------------------------------------------------------
The list of segments I want to emphasize: segments = "AGSGIIISDTPVHDC", "AIDEITNKVNSVIEK", AKSFYKNLIWLVKKG
.
I'm thinking that something that looks like this would work for the emphasis, where the black line is the length of the sequence, and the blue boxes are the segments:
To get start and ending positions of each segment, we can use StringPosition[seq, #] & /@ segments
.
Now I'm not sure which visualization tool would help me visualize this sequence and emphasize the segment using these start and end positions.
list-manipulation visualization segmentation
add a comment |Â
up vote
3
down vote
favorite
I need to visualize a sequence, with the ability to emphasize certain segments.
For example, take this sequence seq
:
seq = -----------------DTLCIGYHANNSTDTVDTVLEKNVTVTHSVNLLEDKHNGKLCK
LRGVAPLHLGKCNIAGWILGNPECESLSTASSWSYIVETPSSDNGTCYPGDFIDYEELREQLSSVSSFER
FEIFPKTSSWPNHDSNKGVTAACPHAGAKSFYKNLIWLVKKGNSYPKLSKSYINDKGKEVLVLWGIHHPS
TSADQQSLYQNADTYVFVGSSRYSKKFKPEIAIRPKVRDQEGRMNYYWTLVEPGDKITFEATGNLVVPRY
AFAMERNAGSGIIISDTPVHDCNTTCQTPKGAINTSLPFQNIHPITIGKCPKYVKSTKLRLATGLRNIPS
G----LFGAIAGFIEGGWTGMVDGWYGYHHQNEQGSGYAADLKSTQNAIDEITNKVNSVIEKMNTQFTAV
GKEFNHLEKRIENLNKKVDDGFLDIWTYNAELLVLLENERTLDYHDSNVKNLYEKVRSQLKNNAKEIGNG
CFEFYHKCDNTCMESVKNGTYDYPKYSEEAKLNREEIDS-------------------------------
--------------------------------------------------------------------
The list of segments I want to emphasize: segments = "AGSGIIISDTPVHDC", "AIDEITNKVNSVIEK", AKSFYKNLIWLVKKG
.
I'm thinking that something that looks like this would work for the emphasis, where the black line is the length of the sequence, and the blue boxes are the segments:
To get start and ending positions of each segment, we can use StringPosition[seq, #] & /@ segments
.
Now I'm not sure which visualization tool would help me visualize this sequence and emphasize the segment using these start and end positions.
list-manipulation visualization segmentation
how aboutStringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?
â kglr
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I need to visualize a sequence, with the ability to emphasize certain segments.
For example, take this sequence seq
:
seq = -----------------DTLCIGYHANNSTDTVDTVLEKNVTVTHSVNLLEDKHNGKLCK
LRGVAPLHLGKCNIAGWILGNPECESLSTASSWSYIVETPSSDNGTCYPGDFIDYEELREQLSSVSSFER
FEIFPKTSSWPNHDSNKGVTAACPHAGAKSFYKNLIWLVKKGNSYPKLSKSYINDKGKEVLVLWGIHHPS
TSADQQSLYQNADTYVFVGSSRYSKKFKPEIAIRPKVRDQEGRMNYYWTLVEPGDKITFEATGNLVVPRY
AFAMERNAGSGIIISDTPVHDCNTTCQTPKGAINTSLPFQNIHPITIGKCPKYVKSTKLRLATGLRNIPS
G----LFGAIAGFIEGGWTGMVDGWYGYHHQNEQGSGYAADLKSTQNAIDEITNKVNSVIEKMNTQFTAV
GKEFNHLEKRIENLNKKVDDGFLDIWTYNAELLVLLENERTLDYHDSNVKNLYEKVRSQLKNNAKEIGNG
CFEFYHKCDNTCMESVKNGTYDYPKYSEEAKLNREEIDS-------------------------------
--------------------------------------------------------------------
The list of segments I want to emphasize: segments = "AGSGIIISDTPVHDC", "AIDEITNKVNSVIEK", AKSFYKNLIWLVKKG
.
I'm thinking that something that looks like this would work for the emphasis, where the black line is the length of the sequence, and the blue boxes are the segments:
To get start and ending positions of each segment, we can use StringPosition[seq, #] & /@ segments
.
Now I'm not sure which visualization tool would help me visualize this sequence and emphasize the segment using these start and end positions.
list-manipulation visualization segmentation
I need to visualize a sequence, with the ability to emphasize certain segments.
For example, take this sequence seq
:
seq = -----------------DTLCIGYHANNSTDTVDTVLEKNVTVTHSVNLLEDKHNGKLCK
LRGVAPLHLGKCNIAGWILGNPECESLSTASSWSYIVETPSSDNGTCYPGDFIDYEELREQLSSVSSFER
FEIFPKTSSWPNHDSNKGVTAACPHAGAKSFYKNLIWLVKKGNSYPKLSKSYINDKGKEVLVLWGIHHPS
TSADQQSLYQNADTYVFVGSSRYSKKFKPEIAIRPKVRDQEGRMNYYWTLVEPGDKITFEATGNLVVPRY
AFAMERNAGSGIIISDTPVHDCNTTCQTPKGAINTSLPFQNIHPITIGKCPKYVKSTKLRLATGLRNIPS
G----LFGAIAGFIEGGWTGMVDGWYGYHHQNEQGSGYAADLKSTQNAIDEITNKVNSVIEKMNTQFTAV
GKEFNHLEKRIENLNKKVDDGFLDIWTYNAELLVLLENERTLDYHDSNVKNLYEKVRSQLKNNAKEIGNG
CFEFYHKCDNTCMESVKNGTYDYPKYSEEAKLNREEIDS-------------------------------
--------------------------------------------------------------------
The list of segments I want to emphasize: segments = "AGSGIIISDTPVHDC", "AIDEITNKVNSVIEK", AKSFYKNLIWLVKKG
.
I'm thinking that something that looks like this would work for the emphasis, where the black line is the length of the sequence, and the blue boxes are the segments:
To get start and ending positions of each segment, we can use StringPosition[seq, #] & /@ segments
.
Now I'm not sure which visualization tool would help me visualize this sequence and emphasize the segment using these start and end positions.
list-manipulation visualization segmentation
list-manipulation visualization segmentation
edited 1 hour ago
J. M. is somewhat okay.â¦
94.6k10293454
94.6k10293454
asked 2 hours ago
briennakh
3669
3669
how aboutStringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?
â kglr
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago
add a comment |Â
how aboutStringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?
â kglr
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago
how about
StringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?â kglr
1 hour ago
how about
StringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?â kglr
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
Graphics[Gray, EdgeForm[Gray], FaceForm[LightBlue],
SequenceReplace[Flatten[Join[1, #[[1]] - 1,
Rectangle[#[[1]], -5, #[[2]], 5], #[[2]] + 1 & /@
StringPosition[seq, s : Alternatives @@ segments], StringLength @ seq]],
a_Integer, b_Integer :> Line[a, 0, b, 0]], ImageSize -> 80]
Alternatively, use NumberLinePlot
:
NumberLinePlot[Interval/@StringPosition[seq, Alternatives @@ segments],
Spacings -> 0, Ticks -> None, ImageSize -> 600,
PlotStyle -> Directive[Opacity[1], PointSize[0], CapForm["Butt"], Thickness[.02]],
PlotRange->0, StringLength @ seq, Automatic]
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
add a comment |Â
up vote
1
down vote
seq must be a string
Graphics[Blue, Line[0, 15, StringLength@seq, 15],
Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Graphics[Gray, EdgeForm[Gray], FaceForm[LightBlue],
SequenceReplace[Flatten[Join[1, #[[1]] - 1,
Rectangle[#[[1]], -5, #[[2]], 5], #[[2]] + 1 & /@
StringPosition[seq, s : Alternatives @@ segments], StringLength @ seq]],
a_Integer, b_Integer :> Line[a, 0, b, 0]], ImageSize -> 80]
Alternatively, use NumberLinePlot
:
NumberLinePlot[Interval/@StringPosition[seq, Alternatives @@ segments],
Spacings -> 0, Ticks -> None, ImageSize -> 600,
PlotStyle -> Directive[Opacity[1], PointSize[0], CapForm["Butt"], Thickness[.02]],
PlotRange->0, StringLength @ seq, Automatic]
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
accepted
Graphics[Gray, EdgeForm[Gray], FaceForm[LightBlue],
SequenceReplace[Flatten[Join[1, #[[1]] - 1,
Rectangle[#[[1]], -5, #[[2]], 5], #[[2]] + 1 & /@
StringPosition[seq, s : Alternatives @@ segments], StringLength @ seq]],
a_Integer, b_Integer :> Line[a, 0, b, 0]], ImageSize -> 80]
Alternatively, use NumberLinePlot
:
NumberLinePlot[Interval/@StringPosition[seq, Alternatives @@ segments],
Spacings -> 0, Ticks -> None, ImageSize -> 600,
PlotStyle -> Directive[Opacity[1], PointSize[0], CapForm["Butt"], Thickness[.02]],
PlotRange->0, StringLength @ seq, Automatic]
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Graphics[Gray, EdgeForm[Gray], FaceForm[LightBlue],
SequenceReplace[Flatten[Join[1, #[[1]] - 1,
Rectangle[#[[1]], -5, #[[2]], 5], #[[2]] + 1 & /@
StringPosition[seq, s : Alternatives @@ segments], StringLength @ seq]],
a_Integer, b_Integer :> Line[a, 0, b, 0]], ImageSize -> 80]
Alternatively, use NumberLinePlot
:
NumberLinePlot[Interval/@StringPosition[seq, Alternatives @@ segments],
Spacings -> 0, Ticks -> None, ImageSize -> 600,
PlotStyle -> Directive[Opacity[1], PointSize[0], CapForm["Butt"], Thickness[.02]],
PlotRange->0, StringLength @ seq, Automatic]
Graphics[Gray, EdgeForm[Gray], FaceForm[LightBlue],
SequenceReplace[Flatten[Join[1, #[[1]] - 1,
Rectangle[#[[1]], -5, #[[2]], 5], #[[2]] + 1 & /@
StringPosition[seq, s : Alternatives @@ segments], StringLength @ seq]],
a_Integer, b_Integer :> Line[a, 0, b, 0]], ImageSize -> 80]
Alternatively, use NumberLinePlot
:
NumberLinePlot[Interval/@StringPosition[seq, Alternatives @@ segments],
Spacings -> 0, Ticks -> None, ImageSize -> 600,
PlotStyle -> Directive[Opacity[1], PointSize[0], CapForm["Butt"], Thickness[.02]],
PlotRange->0, StringLength @ seq, Automatic]
edited 23 mins ago
answered 1 hour ago
kglr
165k8188388
165k8188388
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
add a comment |Â
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
Just had to adjust image size. This answer is amazing because it works for the rest of my segments, as well, which overlap... And it works.
â briennakh
1 hour ago
add a comment |Â
up vote
1
down vote
seq must be a string
Graphics[Blue, Line[0, 15, StringLength@seq, 15],
Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]
add a comment |Â
up vote
1
down vote
seq must be a string
Graphics[Blue, Line[0, 15, StringLength@seq, 15],
Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]
add a comment |Â
up vote
1
down vote
up vote
1
down vote
seq must be a string
Graphics[Blue, Line[0, 15, StringLength@seq, 15],
Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]
seq must be a string
Graphics[Blue, Line[0, 15, StringLength@seq, 15],
Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]
answered 1 hour ago
J42161217
1,706216
1,706216
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183798%2fvisualize-a-string-sequence-emphasizing-certain-substrings%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
how about
StringReplace[seq, s : Alternatives @@ segments :> ToString[Style[s, Red, Bold], StandardForm]]
?â kglr
1 hour ago
That's definitely good, and I actually already had something similar to that, but I need something that's more pictorial, thanks though! @kglr
â briennakh
1 hour ago
I just noticed that this non-pictorial expression would not work with overlapping segments, but your answer below does. @kglr
â briennakh
55 mins ago