Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • serhatg
    Member
    • Mar 2014
    • 10

    Using samtools view function in my own code?

    Hey all,

    I'd like to use samtools view function in my own code in order to map all the reads within some genomic coordinates such as chr1:200000-500000

    There is main_samview function in sam_view.c source code file, however I couldn't figure it out how to use it in this case. Besides, when including sam_view.c in my program I get some compilation errors.

    P.S. What I want to do is to store all the reads belong to a specific region in a vector of strings. I can view the reads in a region my using samtools view file.bam chr1:10000-50000, but I want to store them in a vector inside my program for later use.

    Any help would be appreciated, thank you.
    Last edited by serhatg; 03-28-2014, 12:52 AM. Reason: more details
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    A somewhat outdated version of the API is here. The idea is to not include the C files, but just the bam.h header and then link to libbam.a, which isn't installed anywhere by default...this is somewhat unfortunate though I understand the reasons.

    The actual steps would be as follows:
    1. Parse a region (foo:start-end) into chromosome/contig id (tid), start and end positions.
    2. The these values in bam_fetch()
    3. bam_fetch() calls a user-defined function of the form "typedef int (*bam_fetch_f)(const bam1_t *b, void *data)" for every returned alignment.


    Note that "data" is a pointer to an object that you can control, so presumably whatever buffer you want to store things in.

    Comment

    • serhatg
      Member
      • Mar 2014
      • 10

      #3
      Thanks a lot @dpryan that has been so helpful!

      Comment

      • serhatg
        Member
        • Mar 2014
        • 10

        #4
        Dear dpryan,

        I couldn't figure out a way to store all the allignments in a vector<bam1_t>. I have declared this vector as a global variable rather then sending it by data parameter, and I push back the "const bam1_t *b" object whenever the user defined function is called, but at the end it assigns unreadable data such as to sequence name( Probably I can't manage to deppcopy the value assigned by pointer 'b'). And the cigar strings stored in the core variable of vectors are right when there is just one cigar operation.

        To sum it up, I am looking for a way to store all the allignments belong to the region, which means to store all the return "const bam1_t *b" variables for later use.

        Could you please gimme some idea,

        Thank you.
        Last edited by serhatg; 04-03-2014, 04:42 AM.

        Comment

        • dpryan
          Devon Ryan
          • Jul 2011
          • 3478

          #5
          If you send me the code you have at the moment I'll try to have a look. You can just email it to me (my_username@my_username.com, where my_username=dpryan) if you don't want to post the whole thing somewhere.

          Comment

          Latest Articles

          Collapse

          • mylaser
            Reply to Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
            by mylaser
            Kheloyar – Everything You Need to Know About Kheloyaar Login and Kheoyar Id
            If you are looking for an online gaming platform that offers a user-friendly experience, Kheloyar has become a name that many users search for. Whether you're interested in creating a new account, accessing your dashboard through Kheloyaar Login, or learning how to obtain a Kheoyar Id, understanding the platform's features and account process is essential.
            This guide explains everything you need to know about...
            Today, 01:13 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
          • 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

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 07-09-2026, 10:04 AM
          0 responses
          16 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-08-2026, 10:08 AM
          0 responses
          10 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-07-2026, 11:05 AM
          0 responses
          22 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 07-02-2026, 11:08 AM
          0 responses
          31 views
          0 reactions
          Last Post SEQadmin2  
          Working...