Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hv4
    Junior Member
    • Aug 2011
    • 4

    #1

    trimming bases

    Hi,

    When trimming reads I found Perl to be really slow for large files.

    I wrote this C program to trim at the left and right ends.

    Does this look OK to you?

    #include<stdio.h>

    void main(int argc, char *argv[])
    {
    FILE *fp_in, *fp_out;
    char buffer[1000];
    int count_lines;
    int left_cut;
    int right_cut;

    if (argc!=4)
    {
    printf("Need input and output files and cuts, here's the order:\n");
    printf("Input, output, left cut, right cut (reference from the left)\n");
    return;
    }

    fp_in = fopen(argv[1], "r");
    fp_out = fopen(argv[2], "w");

    sscanf(argv[3],"%d",&left_cut);
    sscanf(argv[4],"%d",&right_cut);

    //printf("\n%d, %d\n", left_cut, right_cut);

    count_lines = 0;

    while(!feof(fp_in))
    {
    fgets(buffer, 1000, fp_in);

    if ((count_lines%2)==0)
    {
    fputs(buffer,fp_out);
    }
    else
    {
    buffer[right_cut]=0;
    fputs(&buffer[left_cut],fp_out);
    fputc('\n',fp_out);
    }

    count_lines++;
    }


    fclose(fp_in);
    fflush(fp_out);
    fclose(fp_out);

    }
  • bioBob
    Member
    • Mar 2011
    • 72

    #2
    Don't forget to remove the mate if your trimming removes the whole read and you are looking at paired end data.

    Comment

    • westerman
      Rick Westerman
      • Jun 2008
      • 1104

      #3
      1) Assumes the arguments are what they are (e.g., file names)
      2) Assumes reads are less than 1000 bases
      3) Assumes reads are strictly header line followed by a single line of bases.
      4) Assumes reads are all the same length
      5) Assumes that the right cut position is not greater than the length of the reads.

      I'd put, up-front, the assumptions so that people are not bitten by them. I'd also do more error checking.

      Comment

      • hv4
        Junior Member
        • Aug 2011
        • 4

        #4
        Thank you for your feedback.

        @bioBob:

        The program does not remove any reads. Just trims them.

        You can use it with paired reads since the program does exactly the same thing
        for both reads.

        @westerman

        Your list is great. Indeed, the program is made to serve a narrow purpose.

        To your list I would also add that the right_cut position specified as a parameter must be +1 than the one intended.

        Comment

        • bioinfosm
          Senior Member
          • Jan 2008
          • 483

          #5
          how does this compare to cutadapt tool?
          --
          bioinfosm

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
            by SEQadmin2



            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
            ...
            Today, 09:55 AM
          • SEQadmin2
            New Genomics Technologies Take Aim at Long-Standing Limits
            by SEQadmin2


            Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

            We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
            ...
            09-28-2026, 10:25 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, Today, 05:39 AM
          0 responses
          9 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, Yesterday, 09:56 AM
          0 responses
          11 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-09-2026, 11:14 AM
          0 responses
          25 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 09-29-2026, 09:51 AM
          0 responses
          76 views
          0 reactions
          Last Post SEQadmin2  
          Working...