SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
mpileup -- bases missing Robby Bioinformatics 2 03-30-2012 01:48 AM
#bases & # reads CS Student General 5 01-21-2012 03:10 AM
random primers with three bases? mboth Sample Prep / Library Generation 2 11-10-2011 04:42 AM
Please Help: What is the differences between standard trimming and adaptive trimming byou678 Bioinformatics 8 08-22-2011 12:05 PM
Periodical illumina read length distribution after trimming of low-quality bases luxmare General 4 12-20-2010 03:18 PM

Reply
 
Thread Tools
Old 04-09-2012, 01:01 PM   #1
hv4
Junior Member
 
Location: TX

Join Date: Aug 2011
Posts: 4
Default 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);

}
hv4 is offline   Reply With Quote
Old 04-10-2012, 04:27 AM   #2
bioBob
Member
 
Location: Virginia

Join Date: Mar 2011
Posts: 72
Default

Don't forget to remove the mate if your trimming removes the whole read and you are looking at paired end data.
bioBob is offline   Reply With Quote
Old 04-10-2012, 06:06 AM   #3
westerman
Rick Westerman
 
Location: Purdue University, Indiana, USA

Join Date: Jun 2008
Posts: 1,104
Default

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.
westerman is offline   Reply With Quote
Old 04-10-2012, 09:44 AM   #4
hv4
Junior Member
 
Location: TX

Join Date: Aug 2011
Posts: 4
Default

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.
hv4 is offline   Reply With Quote
Old 04-10-2012, 06:46 PM   #5
bioinfosm
Senior Member
 
Location: USA

Join Date: Jan 2008
Posts: 482
Default

how does this compare to cutadapt tool?
__________________
--
bioinfosm
bioinfosm is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 02:51 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO