Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Fad2012
    Member
    • Sep 2012
    • 62

    Paired-end reads into two different files

    Hello all

    I am using a software called MetaSim to generate reads based on given genome sequences. My problem is that the reads i produced are paired-ends in one multifasta file. the paired reads look like the following:

    >r1.1 |SOURCES={GI=61252,fw,624-696}|ERRORS={67:A}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
    ATTGGCCATCCGGTGAAAGTGAGACTCATTATCTATCTGTTTGCTGGATCCGCTCCATTGAGTGT
    GTATACT
    >r1.2 |SOURCES={GI=61252,bw,789-861}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
    GCGTTACTAGCTGAATCTCTATAATAATTAATGGTGGTGTAATTAATGGTAGAACCACCATACGC
    TCTATTT
    >r2.1 |SOURCES={GI=61252,fw,6323-6395}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
    CCACCAGTGCTGGCTACCCTTATGTAGCAATGGGAAAGAAGAAGAGAGACATCTTGAACAAACAA
    ACCAGAG
    >r2.2 |SOURCES={GI=61252,bw,6502-6574}|ERRORS={}|SOURCE_1="Human poliovirus 1 Mahoney" (8915ea1a18cb58f4a76d99a56ece2a9018e105bc)
    AGCATATAGGTTCCCAAAAGCCATTCTCATTGCCACTGAGTCATTCAAACTAGAAGCTTCAATTA
    ATCTGGA

    I want the backward reads in a separated file, and the forward reads in another file. Does anyone have any idea about a perl script or any other tool to separate these two reads into two different files; then i will be able to align them using Bowtie or any other alignment tool.

    Many thanks
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    You could just use grep. Something like this should work:
    Code:
    grep -A 1 ".1 " reads.fa > reads_1.fa
    grep -A 1 ".2 " reads.fa > reads_2.fa

    Comment

    • vivek_
      PhD Student
      • Jul 2012
      • 164

      #3
      Originally posted by dpryan View Post
      You could just use grep. Something like this should work:
      Code:
      grep -A 1 ".1 " reads.fa > reads_1.fa
      grep -A 1 ".2 " reads.fa > reads_2.fa
      This should print only the headers and not the sequence right?

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Originally posted by vivek_ View Post
        This should print only the headers and not the sequence right?
        No, check the man page for grep.

        Comment

        • vivek_
          PhD Student
          • Jul 2012
          • 164

          #5
          My bad! Did not notice the -A 1 at the beginning.

          Comment

          • Fad2012
            Member
            • Sep 2012
            • 62

            #6
            Hello

            I still get both 1.1 and 1.2 in the output file. Does it have to do with the extension of my file which is .fna, this how i am doing it; in the terminal i am in the directory where my file is, my file is: test.fna:

            grep -A 1 ".1 " test.fna > reads_1.fna
            grep -A 1 ".2 " test.fna > reads_2.fna

            Many thanks for your help

            Comment

            • dpryan
              Devon Ryan
              • Jul 2011
              • 3478

              #7
              Originally posted by Fad2012 View Post
              Hello

              I still get both 1.1 and 1.2 in the output file. Does it have to do with the extension of my file which is .fna, this how i am doing it; in the terminal i am in the directory where my file is, my file is: test.fna:

              grep -A 1 ".1 " test.fna > reads_1.fna
              grep -A 1 ".2 " test.fna > reads_2.fna

              Many thanks for your help
              Ah, I see that it's treating "." as a match to any character, I should have foreseen that. Try instead:
              Code:
              grep -A 1 "\.1 " test.fna > reads_1.fna
              grep -A 1 "\.2 " test.fna > reads_2.fna
              I should note that, at least under Ubuntu, this results in each read being separated by a "--" line. If that happens for you too, then just add the "--no-group-separator" option (i.e, grep -A 1 --no-group-separator "\.1 " test.fna > reads_1.fna).

              Comment

              • Fad2012
                Member
                • Sep 2012
                • 62

                #8
                Thanks very Much dpryan, it is working now. But yes i do have the separator and when i try to use it, the terminal says: unrecognized option `--no-group-separator'. I am not sure what the reason could be! My terminal is Version 2.3 (309).

                Many thanks!

                Comment

                • GenoMax
                  Senior Member
                  • Feb 2008
                  • 7142

                  #9
                  You can add a second grep to remove the "--"
                  Code:
                  grep -v "\--" reads_1.fna > reads_1_final.fna
                  or you could just add the second grep to the original command

                  Code:
                  grep -A 1 "\.1 " test.fna | grep -v "\--" > reads_1.fna
                  Last edited by GenoMax; 09-28-2012, 06:57 AM.

                  Comment

                  • Fad2012
                    Member
                    • Sep 2012
                    • 62

                    #10
                    Thanks Very much, it is perfectly working!

                    Comment

                    • Smaugt
                      Junior Member
                      • Mar 2013
                      • 2

                      #11
                      Hi all,

                      i have the same problem reported here but if do "grep -v "\--" > reads_1.fna" I also remove lines starting with "--"...
                      Thanks in advance

                      Comment

                      • GenoMax
                        Senior Member
                        • Feb 2008
                        • 7142

                        #12
                        Originally posted by Smaugt View Post
                        Hi all,

                        i have the same problem reported here but if do "grep -v "\--" > reads_1.fna" I also remove lines starting with "--"...
                        Thanks in advance
                        Can you post a small example from your file? Why do you have lines that start with "--"?

                        Comment

                        • Smaugt
                          Junior Member
                          • Mar 2013
                          • 2

                          #13
                          Thanks for ur soon response...

                          OK, I explain better.... I have something like this

                          @IC5OSZZ01DTNH9/1
                          GTTGTCGTGGCTCATGTTCGAGTTATCCATTTGTGCGAATGCGCCTGCTGATACCATG
                          +IC5OSZZ01DTNH9/1
                          --GIIIIIIIIIIII444IIIIEEIEIII444IIIIIIIIIIEGGHIIIII@888EII
                          --

                          if I remove the -- with "grep -v "\--" > reads_1.fna" it'll remove the qualities row too...
                          I hope you can help me..

                          Thanks!

                          Comment

                          • GenoMax
                            Senior Member
                            • Feb 2008
                            • 7142

                            #14
                            What OS are you using?

                            Did you try the "--no-group-separator" option mentioned by Devon in post #7 instead of the second grep?

                            Comment

                            • dpryan
                              Devon Ryan
                              • Jul 2011
                              • 3478

                              #15
                              Originally posted by Smaugt View Post
                              Thanks for ur soon response...

                              OK, I explain better.... I have something like this

                              @IC5OSZZ01DTNH9/1
                              GTTGTCGTGGCTCATGTTCGAGTTATCCATTTGTGCGAATGCGCCTGCTGATACCATG
                              +IC5OSZZ01DTNH9/1
                              --GIIIIIIIIIIII444IIIIEEIEIII444IIIIIIIIIIEGGHIIIII@888EII
                              --

                              if I remove the -- with "grep -v "\--" > reads_1.fna" it'll remove the qualities row too...
                              I hope you can help me..

                              Thanks!
                              Keep in mind that the grep commands that GenoMax and I had mentioned were for use with fasta files, where this situation wouldn't occur. As GenoMax suggested, try the "--no-group-separator" option. If that doesn't work, you can probably still use grep, you just need to change
                              Code:
                              grep -v "\--"
                              into something like
                              Code:
                              grep -v "^--$"
                              or something like that. The idea is to instead do the inverse match for whole lines that are exactly "--".

                              Comment

                              Latest Articles

                              Collapse

                              • mylaser
                                Reply to Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                                by mylaser
                                The world of online gaming has grown tremendously over the past few years, giving players access to exciting sports, casino games, and interactive entertainment from the comfort of their homes. Among the platforms gaining attention, Kheloyaar has become a trusted destination for users seeking a fast, secure, and engaging gaming experience.
                                Whether you're a first-time visitor or an existing user, understanding the features of Kheloyar and the Kheloyaar login process can help you enjoy everything...
                                Today, 12:33 AM
                              • SEQadmin2
                                Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                                by SEQadmin2


                                Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                                The systematic characterization of the human proteome has
                                ...
                                Yesterday, 11:48 AM
                              • SEQadmin2
                                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                                by SEQadmin2



                                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                                ...
                                07-09-2026, 11:10 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Yesterday, 11:10 AM
                              0 responses
                              8 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-13-2026, 10:26 AM
                              0 responses
                              30 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-09-2026, 10:04 AM
                              0 responses
                              39 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-08-2026, 10:08 AM
                              0 responses
                              25 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...