Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • polsum
    Member
    • May 2009
    • 32

    #1

    Bowtie output to BED format

    Hi - Can any one please suggest a method to convert Bowtie output to BED format? Is there a bioperl script or any software for that?

    thanks in advance.
  • polsum
    Member
    • May 2009
    • 32

    #2
    Originally posted by polsum View Post
    Hi - Can any one please suggest a method to convert Bowtie output to BED format? Is there a bioperl script or any software for that?

    thanks in advance.
    Ok I just found out. Save the bowtie output in Sam format, convert it to Bam format by samtools and convert Bam to BED by Bedtools.

    Comment

    • steven
      Senior Member
      • Aug 2009
      • 269

      #3
      Originally posted by polsum View Post
      Ok I just found out. Save the bowtie output in Sam format, convert it to Bam format by samtools and convert Bam to BED by Bedtools.
      hi, thanks for the question + answer and good parsing..

      Comment

      • mattanswers
        Member
        • Oct 2009
        • 65

        #4
        Hi polsum,

        Do you know any Perl ? I have a perl script that will convert bowtie .map file to a .bed file, but you may have to know a little perl to work with it.

        Comment

        • arun
          Junior Member
          • Nov 2010
          • 5

          #5
          bowtie to BED format

          awk 'BEGIN {FS= "\t"; OFS="\t"} {print $3, $4, $4+length($5)-1, $1,
          H=111 $H, $2}' Bowtie_output > Bowtie_output.BED


          This is a shell command, give this command in "$" prompt, it will convert your input file (Bowtie_output) file to BED format (Bowtie_output.BED)

          Last edited by arun; 12-23-2010, 01:16 AM.

          Comment

          • arun
            Junior Member
            • Nov 2010
            • 5

            #6
            awk 'BEGIN {FS= "\t"; OFS="\t"} {print $3, $4, $4+length($5)-1, $1,
            H=111 $H, $2}' Bowtie_output > Bowtie_output.BED

            This is a shell command, give this command in "$" prompt, it will convert your input file (Bowtie_output) file to BED format (Bowtie_output.BED)

            Comment

            • ysccseqanswers
              Junior Member
              • Jul 2012
              • 1

              #7
              Originally posted by arun View Post
              awk 'BEGIN {FS= "\t"; OFS="\t"} {print $3, $4, $4+length($5)-1, $1,
              H=111 $H, $2}' Bowtie_output > Bowtie_output.BED


              This is a shell command, give this command in "$" prompt, it will convert your input file (Bowtie_output) file to BED format (Bowtie_output.BED)

              Hi,

              what is H=111 $H,$2 doing in your command?

              Thanks

              Comment

              • captainentropy
                Member
                • Mar 2009
                • 89

                #8
                Originally posted by ysccseqanswers View Post
                Hi,

                what is H=111 $H,$2 doing in your command?

                Thanks
                With the H=111 and $H I think arun is just setting an awk variable. I'm not sure what use it has actually in this case. The exact same result can be achieved with "...$1,111,$2}..." The 5th column in a bed file is for a score to set the level of gray for each item (http://genome.ucsc.edu/FAQ/FAQformat.html#format1).

                $2 is the 6th column - the strand the read maps to.

                If you wanted a random score for column 5 you could use this in the awk command instead:
                "...$1,int(rand()*1000),$2}..."

                Comment

                • dnewkirk
                  Junior Member
                  • Mar 2009
                  • 8

                  #9
                  Code:
                  #!/usr/bin/perl
                  
                  use strict;
                  use warnings;
                  
                  # get file names from the command line
                  my ($input, $output) = @ARGV;
                  
                  # exceptions and usage
                  if (!defined $input or !defined $output) {
                      die "Usage: bedFromBowtie.pl <input> <output>\n";
                  }
                  
                  # open the input/output file
                  open my $out, ">", "$output" or die "Cannot open $output: $!\n";
                  open my $in, "<", "$input" or die "Cannot open $input: $!\n";
                  
                  while ( <$in> ) {
                      chomp;
                      my (undef, $strand, $chr, $start, $sequence) = split "\t"; # assumes standard bowtie output
                      my @sequence = split '', $sequence; # extra work, but allows for variable-length sequences
                      my $length = @sequence;
                      my $end;
                      if ($strand eq '+') {
                          $end = $start + $length - 1;
                      }
                      elsif ($strand eq '-') {
                          $end = $start;
                          $start = $end - $length + 1;
                      }
                      else {
                          die "We have a formatting problem: strand is set to $strand\n";
                      }
                      print $out "$chr\t$start\t$end\tU0\t0\t$strand\n";
                  }
                  
                  print "Done!\n";
                  
                  close $in; close $out; exit;

                  Comment

                  • captainentropy
                    Member
                    • Mar 2009
                    • 89

                    #10
                    Thanks dnewkirk, could you tell us what would be the advantage to using your perl script would be over an awk command? I'm not criticizing, just wondering. I use an awk command in a shell script to convert.

                    Comment

                    • dnewkirk
                      Junior Member
                      • Mar 2009
                      • 8

                      #11
                      I had posted per the original question without noticing the dates . Either or works, but it may help someone who isn't as familiar with Perl on how to convert between file formats.

                      Comment

                      • captainentropy
                        Member
                        • Mar 2009
                        • 89

                        #12
                        Thanks dnewkirk

                        I always ignore the dates. A question with an answer many months after the OP is still likely to be valuable for someone out there.

                        Comment

                        Latest Articles

                        Collapse

                        • SEQadmin2
                          Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
                          by SEQadmin2



                          CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

                          Despite this, “CRISPR helped turn genome editing from a specialized technique into
                          ...
                          Yesterday, 11:01 AM
                        • SEQadmin2
                          Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                          by SEQadmin2


                          Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                          The systematic characterization of the human proteome has
                          ...
                          07-20-2026, 11:48 AM
                        • 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

                        ad_right_rmr

                        Collapse

                        News

                        Collapse

                        Topics Statistics Last Post
                        Started by SEQadmin2, Yesterday, 02:55 AM
                        0 responses
                        9 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-24-2026, 12:17 PM
                        0 responses
                        12 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-23-2026, 11:41 AM
                        0 responses
                        12 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-20-2026, 11:10 AM
                        0 responses
                        24 views
                        0 reactions
                        Last Post SEQadmin2  
                        Working...