Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dustar1986
    Junior Member
    • Sep 2011
    • 8

    #1

    How to get all contig boundaries from a sorted bam file

    Hi everyone,

    Is there a smart way to assemble reads in the deep sequencing data?
    After aligning reads to the genome using bowtie and samtools, I got the bam file. I want to extend the reads to get contigs if these reads have the same ref chromosome and are on the DNA strand.
    Can I get the start position, end position, ref strand and chromosome number of all these contigs?

    I wrote the following code but it ignore the strand (+/-) the reads come from. Reads from - strand might connected to a + strand one. That's not good.
    Is that possible to extract ref strand info from samtools mpileup?

    My code:

    samtools mpileup input.sorted.bam |\
    cut -d ' ' -f 1,2 |\
    awk -F ' ' 'BEGIN {chr="";start=-1;end=-1} {if(chr!=$1 || int($2)!=end+1) { if(chr!="") {printf("%s:%d-%d\n",chr,start,end);} chr=$1;start=int($2);end=int($2);} else { end=end+1;}} END {if(chr!="") {printf("%s:%d-%d\n",chr,start,end); } }'>output.txt

    And I really want to achieve this in the shell. Any suggestion?

    Thanks a lot.

    Dadi
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    Ignore me: Thought you were working from the SAM/BAM file directly:
    For the strand you'll have to parse the FLAG field, and restricting yourself to shell script makes this much more difficult than it need be. Is using a scripting language really not an option for you?

    Comment

    • dustar1986
      Junior Member
      • Sep 2011
      • 8

      #3
      Originally posted by maubp View Post
      Ignore me: Thought you were working from the SAM/BAM file directly:
      For the strand you'll have to parse the FLAG field, and restricting yourself to shell script makes this much more difficult than it need be. Is using a scripting language really not an option for you?
      No No. Using a scripting language, especially Python, is fine for me. Any suggestion on this please?
      I just thought samtools might be better to deal with sequencing data coz is more "professional" than a script...

      Comment

      • maubp
        Peter (Biopython etc)
        • Jul 2009
        • 1544

        #4
        You can use the samtools C API from a script, e.g. for Python there is PySam,

        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
          ...
          07-31-2026, 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

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 08-06-2026, 07:41 AM
        0 responses
        23 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 08-03-2026, 10:13 AM
        0 responses
        35 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-31-2026, 02:55 AM
        0 responses
        43 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 07-24-2026, 12:17 PM
        0 responses
        26 views
        0 reactions
        Last Post SEQadmin2  
        Working...