Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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


      • #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


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

          Comment


          • #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


            • #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


              • #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


                • #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


                  • #10
                    Thanks Very much, it is perfectly working!

                    Comment


                    • #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


                      • #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


                        • #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


                          • #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


                            • #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

                              • seqadmin
                                Strategies for Sequencing Challenging Samples
                                by seqadmin


                                Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                                03-22-2024, 06:39 AM
                              • seqadmin
                                Techniques and Challenges in Conservation Genomics
                                by seqadmin



                                The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                                Avian Conservation
                                Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                                03-08-2024, 10:41 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, Yesterday, 06:37 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, Yesterday, 06:07 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-22-2024, 10:03 AM
                              0 responses
                              49 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-21-2024, 07:32 AM
                              0 responses
                              67 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X