#!/usr/bin/perl-w Usewarnings; UseStrict;my $usage= qq{$0INPUT_FASTQ trim_length}; die "$usage \ n" if scalar @ARGV!=2;my($FASTQ,$trim _length) =@ARGV;Open(FASTQ,$FASTQ) or die "Can ' t open $FASTQ \ n"; while(my $readid= <FASTQ>) { Chomp $readid; Chomp(my $sequence= <FASTQ>); Chomp(my $comment= <FASTQ>); Chomp(my $quality= <FASTQ>); my $sub _seq=length $sequence<$trim _length?$sequence:substr $sequence,0,$trim _length; my $sub _quality=length $sequence<$trim _length?$quality:substr $quality,0,$trim _length; Printqq{$readid\ n$sub _seq\ n$comment\ n$sub _quality\n};}CloseFASTQ;
FASTQ files Each 4 lines represent a sequence, using a loop that reads 4 rows at a time, and then processes;
When the end of the file is read, the $readid is empty, the loop terminates,
The basic idea is to see defuse (detection of fusion gene tools) source code to see, there is a trim_fastq.pl script, their own slightly modified under;
Used to be Python, the new company is Perl, fortunately, scripting language, it is easier to understand.
Perl intercepts FASTQ files