I have written a PERL script to convert Illumina QSEQ or Export file to FASTQ.
In order to run it, you will need PERL installed.
type in the command: "perl illumina2fastq" to get the help.
typical command:
perl illumina2fastq -i input_qseq.txt -o output.fastq
The script is as below (Please save the script as "illumina2fastq"):
===============================================
#!/usr/bin/perl -w
### Script: illumina2fastq
### Author: ngs-interest.blogspot.com
### Last Update: 7 September 2011
use strict;
use Getopt::Long;
use Pod::Usage;
use POSIX;
=head1 NAME
illumina2fastq
=head1 SYNOPSIS
illumina2fastq -[options]
-h - help
-i - input file (qseq or export file)
-o - output file (default: write to out.fastq)
example:
illumina2fastq -i input_qseq.txt ### input_qseq.txt is the "qseq" file and write output to out.fastq
illumina2fastq -i input_qseq.txt -o outputfile.fastq ### input_qseq.txt is the "qseq" file and write output to outputfile.fastq
=head1 DESCRIPTION
This script aims to create FASTQ file from the "qseq.txt" or "export.txt" file.
=cut
### option variables
my $help;
my $inFile;
my $outFile;
my $phredOffset;
### initialize option
Getopt::Long::Configure ('bundling');
if ( !GetOptions ('h'=>\$help, 'i=s'=>\$inFile, 'o=s'=>\$outFile) || !defined($inFile) ) {
if ($help) {
pod2usage(-verbose => 2);
} else {
pod2usage(1);
}
}
### Initialize all variables
if (!defined($outFile)) {
$outFile = "out.fastq";
}
if (!defined($phredOffset)) {
$phredOffset = 0;
}
### Printing Information
print STDERR "Input File\t\t: $inFile\n";
print STDERR "Output File\t\t: $outFile\n";
print STDERR "\n";
print "Creating $outFile file...\n";
### File Initialization
open (IN, $inFile) || die "Cannot open $inFile for reading!\n";
open (OUT, ">$outFile") || die "Cannot open $outFile for writing!\n";
while (<IN>) {
chomp;
my @f = split(/\t/);
$f[8] =~ s/\./N/g;
my $id = "$f[0]-$f[1]-$f[2]-$f[3]-$f[4]-$f[5]";
print OUT "\@$id\n$f[8]\n+$id\n$f[9]\n";
}
close (IN);
close (OUT);
print STDERR "Finish writing $outFile\n";
##=============================
Showing posts with label FASTQ. Show all posts
Showing posts with label FASTQ. Show all posts
Monday, September 5, 2011
FASTQ file
FASTQ file is actually just a text file which store the reads generated from Next Generation Sequencer.
Each read is represented as four lines in the FASTQ file:
1. First line is always started by a special character '@' followed by the read ID
2. Second line is the nucleotide sequence of the read ID in first line.
3. Third line is always started by a special character '+' followed by any description. The description can be empty.
4. Fourth line is the base quality of the sequence in line 2. The base quality is encoded using ASCII character for brevity. Please note that the base quality encoding can be Phred+33, Phred+64 or Solexa+64
An example of a read (length 32bp) being represented in FASTQ file is as follow:
@read1
ACGTACGTACGTACGTACGTACGTACGTACTG
+
**(01+(*!!!9999987234963024-3+34
The base quality for the above example is encoded using Phred+33. Therefore, referring to the ASCII table, the character '*' is actually equal to 42. Since this is Phred+33 encoding, therefore the Phred score = 42-33 = 9.
It is important to know the base quality encoding prior to alignment.
Each read is represented as four lines in the FASTQ file:
1. First line is always started by a special character '@' followed by the read ID
2. Second line is the nucleotide sequence of the read ID in first line.
3. Third line is always started by a special character '+' followed by any description. The description can be empty.
4. Fourth line is the base quality of the sequence in line 2. The base quality is encoded using ASCII character for brevity. Please note that the base quality encoding can be Phred+33, Phred+64 or Solexa+64
An example of a read (length 32bp) being represented in FASTQ file is as follow:
@read1
ACGTACGTACGTACGTACGTACGTACGTACTG
+
**(01+(*!!!9999987234963024-3+34
The base quality for the above example is encoded using Phred+33. Therefore, referring to the ASCII table, the character '*' is actually equal to 42. Since this is Phred+33 encoding, therefore the Phred score = 42-33 = 9.
It is important to know the base quality encoding prior to alignment.
Subscribe to:
Posts (Atom)