Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • #16
    Have you tried reformat.sh that is part of BBMap suite (http://seqanswers.com/forums/showthr...=reformat.sh)?
    You should be able to get back the lane specific files (you will need to parse them out) as long as fastq identifier was not changed.

    Comment


    • #17
      Sam/bam to fastq is tricky for a couple reasons:

      1) Sam format requires read 1 and read 2 have identical names, which will necessarily strip off some information when they don't - for example, Illumina reads typically have " /1" and " /2" at the end or something similar to indicate read 1 and read 2. This cannot be recovered; typically, everything after the first whitespace is removed.
      2) Sam format can have have an arbitrary number of lines per fastq read, and they are not necessarily in any particular order.
      3) If the sam file is hard-clipped, bases will be lost.

      Therefore, no, in the general case it is impossible to get the 100% identical original fastq from some arbitrary bam file. Reformat will do a fairly good job, though, if you run it with the "primaryonly" flag. If the bam file was sorted, then you can use the accompanying repair.sh script to reorder the resulting fastq file so that pairs are together.

      Comment


      • #18
        There is also
        Code:
        samtools bam2fq
        although there is a bug where it gives FASTA records instead of FASTQ records if your SAM/BAM file is missing qualities:
        The name suggests the samtools bam2fq command will output FASTQ files, however it appears to produce FASTA records for reads with just * as their QUAL: $ ./samtools 2>&1 | grep -i Version: Version:...

        Comment


        • #19
          Hi everyone,

          the ever impressive bedtools also has a BAM-to-FASTQ utility ( http://bedtools.readthedocs.org/en/l...amtofastq.html )

          Comment


          • #20
            Originally posted by maxsalm View Post
            Hi everyone,

            the ever impressive bedtools also has a BAM-to-FASTQ utility ( http://bedtools.readthedocs.org/en/l...amtofastq.html )
            Hello I have bedtools but not succeeded.

            here is the error!

            bedtools bamtofastq -i lib4seq.align.qsort.bam -fq lib4_align.end1.fq -fq2 lib4_align.end2.fq
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:5288:17174 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:5769:20128 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:5815:17504 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:5824:20930 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:5991:18768 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.
            *****WARNING: Query M01601:32:000000000-A7VGV:1:1101:6432:20279 is marked as paired, but it's mate does not occur next to it in your BAM file. Skipping.


            where is the problem?

            Comment


            • #21
              Your reads are most presumably position-sorted. The bedtools (and many other tools) like to have it name-sorted:
              Note
              When using this option, it is required that the BAM file is sorted/grouped by the read name. This keeps the resulting records in the two output FASTQ files in the same order. One can sort the BAM file by query name with samtools sort -n aln.bam aln.qsort.

              Comment


              • #22
                Then I could be on the right track.
                Here is the command i issued: samtools sort -n lib4seq.sorted.mapped.bam lib4seq.align.qsort

                Comment


                • #23
                  Hello,

                  I'm quite new to this forum and bioanformatic!
                  I have bam file from the Ion toront and want to convert them to fastq file. I've tried picard SamToFastq command but got error all the time.
                  This is how I used it:

                  java picard-tools/SamToFastq.jar I=filename.bam F=filename.fastq

                  Is there something wrong in the command?
                  I've tried to figure out how should I write the command and tried many versions, none of the worked!!

                  I'll appreciate any help

                  Comment


                  • #24
                    Are you using the latest version of Picard tools? As shown on the help page your command line should look something like:
                    Code:
                    $ java -jar path_to/picard.jar SamToFastq INPUT=filename.bam OUTPUT=filename.fastq

                    Comment


                    • #25
                      Hi

                      this code works for me :

                      java -jar -Xmx4g SamToFastq.jar INPUT=file.bam F=file.fastq VALIDATION_STRINGENCY=LENIENT

                      bye

                      Comment


                      • #26
                        I would use samtools:

                        Code:
                        samtools bam2fq file.bam > file.fq
                        List of options:

                        Code:
                        Usage: samtools bam2fq [options...] <in.bam>
                        Options:
                          -0 FILE   write paired reads flagged both or neither READ1 and READ2 to FILE
                          -1 FILE   write paired reads flagged READ1 to FILE
                          -2 FILE   write paired reads flagged READ2 to FILE
                          -f INT    only include reads with all bits set in INT set in FLAG [0]
                          -F INT    only include reads with none of the bits set in INT set in FLAG [0]
                          -n        don't append /1 and /2 to the read name
                          -O        output quality in the OQ tag if present
                          -s FILE   write singleton reads to FILE [assume single-end]
                          -t        copy RG, BC and QT tags to the FASTQ header line
                          -v INT    default quality score if not given in file [1]
                              --input-fmt-option OPT[=VAL]
                                       Specify a single input file format option in the form
                                       of OPTION or OPTION=VALUE
                              --reference FILE
                                       Reference sequence FASTA FILE [null]

                        Comment


                        • #27
                          Thank you all for the help, but none of worked and I do use latest version of picard.

                          I could you samtools bam2fq file, the command worked but it created empty fq files!

                          Don't know really what to do!

                          Comment


                          • #28
                            Hi Eli,

                            if everything fails, you can still use the bash to format a bam-file to a fastq-file. A sam-file is structured in a way, that you can extract the first, tenth and eleventh field (see sam and fastqc specs):
                            Code:
                            samtools view file.bam | awk '{printf "@%s\n%s\n+\n%s\n", $1,$10,$11}' > file.fastq
                            If your read-ID has already the "@" as a first character in the bam file, you can remove that in the awk command.
                            Nevertheless, this will take a bit longer.

                            Comment


                            • #29
                              @Eli-2016: You may have a malformed BAM file (or the file is not in BAM format). Do you see properly formatted lines if you do

                              Code:
                              $ samtools view file.bam | more
                              What is the output of

                              Code:
                              $ file file.bam

                              Comment

                              Latest Articles

                              Collapse

                              • seqadmin
                                Current Approaches to Protein Sequencing
                                by seqadmin


                                Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
                                04-04-2024, 04:25 PM
                              • 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

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, 04-11-2024, 12:08 PM
                              0 responses
                              25 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-10-2024, 10:19 PM
                              0 responses
                              29 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-10-2024, 09:21 AM
                              0 responses
                              24 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 04-04-2024, 09:00 AM
                              0 responses
                              52 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X