Replace lowercase characters with -

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
I have found simple solution to replace all lowercase to uppercase:



awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna


but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks










share|improve this question







New contributor




robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    1
    down vote

    favorite












    I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
    I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
    I have found simple solution to replace all lowercase to uppercase:



    awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna


    but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks










    share|improve this question







    New contributor




    robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
      I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
      I have found simple solution to replace all lowercase to uppercase:



      awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna


      but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks










      share|improve this question







      New contributor




      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I have an output from vcfutils.pl vcf2fq with specified minimal depth, and it means that nucleotides with not enough depth are lowercase.
      I would like to change them to gaps. I could do it in higher language but I would like to know the solution in bash.
      I have found simple solution to replace all lowercase to uppercase:



      awk 'BEGINFS=" "if(!/>/)print toupper($0)elseprint $1' in.fna > out.fna


      but I would like to replace lowercase with -. The first row need to be omitted. Could you help me? Thanks







      bash shell






      share|improve this question







      New contributor




      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 7 hours ago









      robinj

      62




      62




      New contributor




      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      robinj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          3
          down vote













          The following sed command will do the trick.



          sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna



          Lines starting with > will be escaped and the lowercase characters will be replaced with - .






          share|improve this answer



























            up vote
            2
            down vote













            You could try it with sed.

            Replace all lower-case chars with - in lines not starting with >:



            sed -e '/^>/!s/[a-z]/-/g' in.fa





            share|improve this answer





























              up vote
              1
              down vote













              You can also use this solution where tr command from linux can solve your problem:



              tail -n +2 in.fna | tr '[:lower:]' '-'






              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: "676"
                ;
                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: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                imageUploader:
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                ,
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );






                robinj is a new contributor. Be nice, and check out our Code of Conduct.









                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbioinformatics.stackexchange.com%2fquestions%2f5380%2freplace-lowercase-characters-with%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                3
                down vote













                The following sed command will do the trick.



                sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna



                Lines starting with > will be escaped and the lowercase characters will be replaced with - .






                share|improve this answer
























                  up vote
                  3
                  down vote













                  The following sed command will do the trick.



                  sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna



                  Lines starting with > will be escaped and the lowercase characters will be replaced with - .






                  share|improve this answer






















                    up vote
                    3
                    down vote










                    up vote
                    3
                    down vote









                    The following sed command will do the trick.



                    sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna



                    Lines starting with > will be escaped and the lowercase characters will be replaced with - .






                    share|improve this answer












                    The following sed command will do the trick.



                    sed -e '/^[^>]/ s/[a-z]/-/g' in.fna > out.fna



                    Lines starting with > will be escaped and the lowercase characters will be replaced with - .







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 6 hours ago









                    arupgsh

                    430111




                    430111




















                        up vote
                        2
                        down vote













                        You could try it with sed.

                        Replace all lower-case chars with - in lines not starting with >:



                        sed -e '/^>/!s/[a-z]/-/g' in.fa





                        share|improve this answer


























                          up vote
                          2
                          down vote













                          You could try it with sed.

                          Replace all lower-case chars with - in lines not starting with >:



                          sed -e '/^>/!s/[a-z]/-/g' in.fa





                          share|improve this answer
























                            up vote
                            2
                            down vote










                            up vote
                            2
                            down vote









                            You could try it with sed.

                            Replace all lower-case chars with - in lines not starting with >:



                            sed -e '/^>/!s/[a-z]/-/g' in.fa





                            share|improve this answer














                            You could try it with sed.

                            Replace all lower-case chars with - in lines not starting with >:



                            sed -e '/^>/!s/[a-z]/-/g' in.fa






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 5 hours ago









                            Llopis

                            2,5471628




                            2,5471628










                            answered 6 hours ago









                            Peter Menzel

                            1137




                            1137




















                                up vote
                                1
                                down vote













                                You can also use this solution where tr command from linux can solve your problem:



                                tail -n +2 in.fna | tr '[:lower:]' '-'






                                share|improve this answer
























                                  up vote
                                  1
                                  down vote













                                  You can also use this solution where tr command from linux can solve your problem:



                                  tail -n +2 in.fna | tr '[:lower:]' '-'






                                  share|improve this answer






















                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    You can also use this solution where tr command from linux can solve your problem:



                                    tail -n +2 in.fna | tr '[:lower:]' '-'






                                    share|improve this answer












                                    You can also use this solution where tr command from linux can solve your problem:



                                    tail -n +2 in.fna | tr '[:lower:]' '-'







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 4 hours ago









                                    Ammar Sabir Cheema

                                    548213




                                    548213




















                                        robinj is a new contributor. Be nice, and check out our Code of Conduct.









                                         

                                        draft saved


                                        draft discarded


















                                        robinj is a new contributor. Be nice, and check out our Code of Conduct.












                                        robinj is a new contributor. Be nice, and check out our Code of Conduct.











                                        robinj is a new contributor. Be nice, and check out our Code of Conduct.













                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fbioinformatics.stackexchange.com%2fquestions%2f5380%2freplace-lowercase-characters-with%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        Comments

                                        Popular posts from this blog

                                        What does second last employer means? [closed]

                                        Installing NextGIS Connect into QGIS 3?

                                        One-line joke