Visualize a string/sequence, emphasizing certain substrings

The name of the pictureThe name of the pictureThe name of the pictureClash 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:



enter image description here



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.










share|improve this question























  • 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















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:



enter image description here



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.










share|improve this question























  • 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













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:



enter image description here



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.










share|improve this question















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:



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago









J. M. is somewhat okay.♦

94.6k10293454




94.6k10293454










asked 2 hours ago









briennakh

3669




3669











  • 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

















  • 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
















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











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]


enter image description here



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]


enter image description here






share|improve this answer






















  • 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


















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]]


enter image description here






share|improve this answer




















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "387"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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]


    enter image description here



    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]


    enter image description here






    share|improve this answer






















    • 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















    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]


    enter image description here



    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]


    enter image description here






    share|improve this answer






















    • 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













    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]


    enter image description here



    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]


    enter image description here






    share|improve this answer














    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]


    enter image description here



    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]


    enter image description here







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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

















    • 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











    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]]


    enter image description here






    share|improve this answer
























      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]]


      enter image description here






      share|improve this answer






















        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]]


        enter image description here






        share|improve this answer












        seq must be a string



        Graphics[Blue, Line[0, 15, StringLength@seq, 15], 
        Rectangle[#, 0, #2, 30] & @@@ StringPosition[seq, segments]]


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        J42161217

        1,706216




        1,706216



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery