Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • 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);

    }

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

    Comment


    • #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


      • #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


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

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Latest Developments in Precision Medicine
            by seqadmin



            Technological advances have led to drastic improvements in the field of precision medicine, enabling more personalized approaches to treatment. This article explores four leading groups that are overcoming many of the challenges of genomic profiling and precision medicine through their innovative platforms and technologies.

            Somatic Genomics
            “We have such a tremendous amount of genetic diversity that exists within each of us, and not just between us as individuals,”...
            05-24-2024, 01:16 PM
          • seqadmin
            Recent Advances in Sequencing Analysis Tools
            by seqadmin


            The sequencing world is rapidly changing due to declining costs, enhanced accuracies, and the advent of newer, cutting-edge instruments. Equally important to these developments are improvements in sequencing analysis, a process that converts vast amounts of raw data into a comprehensible and meaningful form. This complex task requires expertise and the right analysis tools. In this article, we highlight the progress and innovation in sequencing analysis by reviewing several of the...
            05-06-2024, 07:48 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 06:55 AM
          0 responses
          12 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-30-2024, 03:16 PM
          0 responses
          24 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-29-2024, 01:32 PM
          0 responses
          28 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 05-24-2024, 07:15 AM
          0 responses
          215 views
          0 likes
          Last Post seqadmin  
          Working...
          X