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

                              • 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
                              • SEQadmin2
                                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                                by SEQadmin2



                                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                                07-08-2026, 05:17 AM
                              • GATTACAT
                                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                                by GATTACAT
                                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                                07-01-2026, 11:43 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by SEQadmin2, Today, 10:26 AM
                              0 responses
                              10 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-09-2026, 10:04 AM
                              0 responses
                              24 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-08-2026, 10:08 AM
                              0 responses
                              16 views
                              0 reactions
                              Last Post SEQadmin2  
                              Started by SEQadmin2, 07-07-2026, 11:05 AM
                              0 responses
                              33 views
                              0 reactions
                              Last Post SEQadmin2  
                              Working...