Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • wmseq
    Member
    • May 2011
    • 71

    How to combine all the seqences in a fasta file to one sequence?

    Hi every one,

    I have a fasta file like this like this:
    >GL132456
    ABCDEDERFSE
    >GL123456
    ABDFDRAGDTGEGAGFDAS
    >GL125436
    AFGHSRSGFGSHSFG
    I want to combine all the sequences to one sequence, like this:
    ABCDEDERFSEABDFDRAGDTGEGAGFDASAFGHSRSGFGSHSFG

    Thanks a lot!

    Richard
  • rhinoceros
    Senior Member
    • Apr 2013
    • 372

    #2
    Maybe:

    Code:
    grep -v ">" your.fasta | sed -e 's/\n//g' -e 's/ //g' > youredited.fasta
    Select all lines than don't have ">", remove newlines, remove spaces, direct output to a new file.
    Last edited by rhinoceros; 10-26-2013, 06:03 PM.
    savetherhino.org

    Comment

    • fahmida
      Member
      • Aug 2010
      • 54

      #3
      Originally posted by rhinoceros View Post
      Maybe:

      Code:
      grep -v ">" your.fasta | sed -e 's/\n//g' -e 's/ //g' > youredited.fasta
      Select all lines than don't begin with ">", remove newlines, remove spaces, direct output to a new file.
      Just a minor update of above would create the required output:

      Code:
      grep -v ">" your.fasta|tr '\n' ' ' | sed -e 's/ //g' > youredited.fasta
      Output:

      ABCDEDERFSEABDFDRAGDTGEGAGFDASAFGHSRSGFGSHSFG

      Comment

      • liweixie
        Member
        • Oct 2013
        • 21

        #4
        use cat command

        Comment

        • wmseq
          Member
          • May 2011
          • 71

          #5
          I have checked all the commands. No one worked for my data.
          Thanks!

          Comment

          • rhinoceros
            Senior Member
            • Apr 2013
            • 372

            #6
            Originally posted by wmseq View Post
            I have checked all the commands. No one worked for my data.
            Thanks!
            You're doing it wrong then because they do work:

            Code:
            $ cat file.fasta 
            >GL132456
            ABCDEDERFSE
            >GL123456
            ABDFDRAGDTGEGAGFDAS
            >GL125436
            AFGHSRSGFGSHSFG
            
            $ grep -v ">" file.fasta | tr '\n' ' ' | sed -e 's/ //g' > youredited.fasta
            
            $ cat youredited.fasta 
            ABCDEDERFSEABDFDRAGDTGEGAGFDASAFGHSRSGFGSHSFG
            savetherhino.org

            Comment

            • wmseq
              Member
              • May 2011
              • 71

              #7
              I am sorry for my mistake, because my sequence is as follows.
              >GL132456
              ABCDEDERFSE
              DGA
              >GL123456
              ABDFDRAGDTGEGAGFDAS
              >GL125436
              AFGHSRSGFGSHSFG

              After I used the commands, I got the following sequence with white space in it.
              ABCDEDERFSE
              DGA
              ABDFDRAGDTGEGAGFDASAFGHSRSGFGSHSFG

              thank you for your patience!
              Last edited by wmseq; 10-28-2013, 07:05 AM.

              Comment

              • RDW
                Member
                • Oct 2008
                • 63

                #8
                perl -pe 'chomp;s/>.+//' input.fasta >out.txt

                Comment

                Latest Articles

                Collapse

                • seqadmin
                  Pathogen Surveillance with Advanced Genomic Tools
                  by seqadmin




                  The COVID-19 pandemic highlighted the need for proactive pathogen surveillance systems. As ongoing threats like avian influenza and newly emerging infections continue to pose risks, researchers are working to improve how quickly and accurately pathogens can be identified and tracked. In a recent SEQanswers webinar, two experts discussed how next-generation sequencing (NGS) and machine learning are shaping efforts to monitor viral variation and trace the origins of infectious...
                  Today, 11:48 AM
                • seqadmin
                  New Genomics Tools and Methods Shared at AGBT 2025
                  by seqadmin


                  This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

                  The Headliner
                  The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
                  03-03-2025, 01:39 PM
                • seqadmin
                  Investigating the Gut Microbiome Through Diet and Spatial Biology
                  by seqadmin




                  The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
                  02-24-2025, 06:31 AM

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by seqadmin, 03-20-2025, 05:03 AM
                0 responses
                26 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-19-2025, 07:27 AM
                0 responses
                33 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-18-2025, 12:50 PM
                0 responses
                25 views
                0 reactions
                Last Post seqadmin  
                Started by seqadmin, 03-03-2025, 01:15 PM
                0 responses
                190 views
                0 reactions
                Last Post seqadmin  
                Working...