Header Leaderboard Ad

Collapse

Paired-end reads into two different files

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
                          [email protected]
                          --

                          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
                              [email protected]
                              --

                              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
                                Improved Targeted Sequencing: A Comprehensive Guide to Amplicon Sequencing
                                by seqadmin



                                Amplicon sequencing is a targeted approach that allows researchers to investigate specific regions of the genome. This technique is routinely used in applications such as variant identification, clinical research, and infectious disease surveillance. The amplicon sequencing process begins by designing primers that flank the regions of interest. The DNA sequences are then amplified through PCR (typically multiplex PCR) to produce amplicons complementary to the targets. RNA targets...
                                Today, 01:49 PM
                              • seqadmin
                                Targeted Sequencing: Choosing Between Hybridization Capture and Amplicon Sequencing
                                by seqadmin




                                Targeted sequencing is an effective way to sequence and analyze specific genomic regions of interest. This method enables researchers to focus their efforts on their desired targets, as opposed to other methods like whole genome sequencing that involve the sequencing of total DNA. Utilizing targeted sequencing is an attractive option for many researchers because it is often faster, more cost-effective, and only generates applicable data. While there are many approaches...
                                03-10-2023, 05:31 AM
                              • seqadmin
                                Expert Advice on Automating Your Library Preparations
                                by seqadmin



                                Using automation to prepare sequencing libraries isn’t a new concept, and most researchers are aware that there are numerous benefits to automating this process. However, many labs are still hesitant to switch to automation and often believe that it’s not suitable for their lab. To combat these concerns, we’ll cover some of the key advantages, review the most important considerations, and get real-world advice from automation experts to remove any lingering anxieties....
                                02-21-2023, 02:14 PM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, 03-17-2023, 12:32 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-15-2023, 12:42 PM
                              0 responses
                              18 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-09-2023, 10:17 AM
                              0 responses
                              67 views
                              1 like
                              Last Post seqadmin  
                              Started by seqadmin, 03-03-2023, 12:03 PM
                              0 responses
                              64 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X