Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pepperoni
    Member
    • Oct 2011
    • 59

    #1

    Tool for counting mismatches in hundreds of files?

    Hello, I need to align 2 sequences in hundreds of files and then write a list with the count of the mismatches in each file.

    I thought I could use muscle for the alignments as it can run in command line and write a script to run all my files but then how do I count the mismatches of each alignment?

    since they are just two protein sequences in each file I cannot use bowtie or similar. I also thought that maybe there is a way to convert a phylip or clustal format into sam so I can use some snp calling tools.

    Does any one know how can I align and count the mismatches of all my files?
  • rflrob
    Member
    • May 2010
    • 50

    #2
    This snippet of python might do the trick for you, for the simplest possible definition of "counting mismatches", where that's any column where it's not all identical. It assumes you have BioPython installed, and that you've done your alignments in Clustal format (MUSCLE claims to be able to output in this format, and I have no reason to disbelieve it).

    Code:
    from Bio import AlignIO
    from glob import glob
    
    for file in glob('*.aln'):
        a = AlignIO.read(file, 'clustal')
        print file, len([1 for i in range(a.get_alignment_length())
                         if len(set(a[:,i])) != 1])
        # Iterate over the alignment in a list comprehension, and only keep 
        # elements where there's more than one value.

    Comment

    • Richard Finney
      Senior Member
      • Feb 2009
      • 701

      #3
      "blat" by Jim Kent of UCSC is a good tool.

      There are various methods for structuring a command batch file to process (input data) files.

      blat (PSL format) output contains a count of the number of mis matches.
      Last edited by Richard Finney; 09-13-2013, 11:21 AM.

      Comment

      • pepperoni
        Member
        • Oct 2011
        • 59

        #4
        Many thanks to both of you for your quick replies. I have just tried rflrob's python script, and it works great

        Originally posted by rflrob View Post
        This snippet of python might do the trick for you, for the simplest possible definition of "counting mismatches", where that's any column where it's not all identical. It assumes you have BioPython installed, and that you've done your alignments in Clustal format (MUSCLE claims to be able to output in this format, and I have no reason to disbelieve it).

        Code:
        from Bio import AlignIO
        from glob import glob
        
        for file in glob('*.aln'):
            a = AlignIO.read(file, 'clustal')
            print file, len([1 for i in range(a.get_alignment_length())
                             if len(set(a[:,i])) != 1])
            # Iterate over the alignment in a list comprehension, and only keep 
            # elements where there's more than one value.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
          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, detection...
          Today, 06:46 AM
        • SEQadmin2
          Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
          by SEQadmin2



          Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

          Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
          ...
          10-14-2026, 09:55 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by SEQadmin2, 10-28-2026, 09:57 AM
        0 responses
        24 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-28-2026, 09:51 AM
        0 responses
        15 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 11:13 AM
        0 responses
        68 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 10-22-2026, 10:48 AM
        0 responses
        48 views
        0 reactions
        Last Post SEQadmin2  
        Working...