Unconfigured Ad

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

    #1

    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

                              • SEQadmin2
                                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                                by SEQadmin2



                                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                                ...
                                10-14-2026, 09:55 AM
                              • SEQadmin2
                                New Genomics Technologies Take Aim at Long-Standing Limits
                                by SEQadmin2


                                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                                ...
                                09-28-2026, 10:25 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, 10-15-2026, 10:52 AM
                              0 responses
                              14 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-14-2026, 05:39 AM
                              0 responses
                              21 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-13-2026, 09:56 AM
                              0 responses
                              19 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 10-09-2026, 11:14 AM
                              0 responses
                              27 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...