I am trying to use various datasets from hudson alpha and the fastq files have dots in them. I don't know how to remove the dots. I'm not really a programmer, but I did try to remove them using grep from the command line. I thought it worked, because it got rid of some lines. But I didn't get rid of all of them. I think the problem has something to do with grooming them. Does anyone know how to get rid of these dots?
Unconfigured Ad
Collapse
X
-
What kind of reads are those? Are they short reads, and only have a single line per read, or do they span several lines per read? If they span several lines per read, I'd parse them with BioPython's SeqIO and do the replacement in there:Originally posted by Giles View PostI am trying to use various datasets from hudson alpha and the fastq files have dots in them. I don't know how to remove the dots. I'm not really a programmer, but I did try to remove them using grep from the command line. I thought it worked, because it got rid of some lines. But I didn't get rid of all of them. I think the problem has something to do with grooming them. Does anyone know how to get rid of these dots?
The above code can be used as follows (save the code in fastq_replace_dots_with_Ns_in_seq.py):Code:import sys from Bio import Seq, SeqRecord, SeqIO for record in SeqIO.parse(sys.stdin,"fastq-sanger"): SeqIO.write(SeqRecord.SeqRecord(seq=Seq.Seq(str(record.seq).replace(".","N")),letter_annotations=record.letter_annotations,id=record.id,name=record.name,description=record.description),sys.stdout,"fastq-sanger")
cat fastq_with_dots.fq | python fastq_replace_dots_with_Ns_in_seq.py > fastq_with_Ns.fq
If they are single line reads, an awk solution should be quite easily possible as well. A simple search/replace of "." will not work if you have a Sanger Phred encoded file, however, since "." is a valid quality score in a +33 encoding. Also, just simply dropping lines with dots will lead to a corrupted file - don't do that.
Anyways, beware that a IUPAC dot means an gap of unknown size, which is distinct from an N (any *one* base), so be careful with how the downstream alignment is done, especially if the reads come from a technology that delivers long gaps in the reads.
-
If that turns out to be a bit slow, you could drop down to plain Python strings instead, e.g.Originally posted by arvid View PostWhat kind of reads are those? Are they short reads, and only have a single line per read, or do they span several lines per read? If they span several lines per read, I'd parse them with BioPython's SeqIO and do the replacement in there:
See also http://news.open-bio.org/news/2009/0...on-fast-fastq/Code:import sys from Bio.SeqIO.QualityIO import FastqGeneralIterator for title, seq, qual in FastqGeneralIterator(sys.stdin): print "@%s\n%s\n+\n%s" % (title, seq.replace(".", "N"), qual)
Comment
Latest Articles
Collapse
-
by SEQadmin2
When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...-
Channel: Articles
Today, 07:04 AM -
-
by SEQadmin2
NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...-
Channel: Articles
10-30-2026, 06:46 AM -
ad_right_rmr
Collapse
News
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SEQadmin2, Yesterday, 11:11 AM
|
0 responses
14 views
0 reactions
|
Last Post
by SEQadmin2
Yesterday, 11:11 AM
|
||
|
Started by SEQadmin2, 11-17-2026, 06:27 AM
|
0 responses
39 views
0 reactions
|
Last Post
by SEQadmin2
11-17-2026, 06:27 AM
|
||
|
Started by SEQadmin2, 11-12-2026, 07:59 AM
|
0 responses
55 views
0 reactions
|
Last Post
by SEQadmin2
11-12-2026, 07:59 AM
|
||
|
Started by SEQadmin2, 11-05-2026, 09:25 AM
|
0 responses
61 views
0 reactions
|
Last Post
by SEQadmin2
11-05-2026, 09:25 AM
|
Comment