Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • grooming fastq dots to N's

    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?

  • #2
    Originally posted by Giles View Post
    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?
    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:
    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")
    The above code can be used as follows (save the code in fastq_replace_dots_with_Ns_in_seq.py):
    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.

    Comment


    • #3
      Originally posted by arvid View Post
      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:
      If that turns out to be a bit slow, you could drop down to plain Python strings instead, e.g.
      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)
      See also http://news.open-bio.org/news/2009/0...on-fast-fastq/

      Comment

      Latest Articles

      Collapse

      • seqadmin
        Essential Discoveries and Tools in Epitranscriptomics
        by seqadmin




        The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
        04-22-2024, 07:01 AM
      • seqadmin
        Current Approaches to Protein Sequencing
        by seqadmin


        Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
        04-04-2024, 04:25 PM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, Today, 11:49 AM
      0 responses
      10 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, Yesterday, 08:47 AM
      0 responses
      16 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-11-2024, 12:08 PM
      0 responses
      61 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 10:19 PM
      0 responses
      60 views
      0 likes
      Last Post seqadmin  
      Working...
      X