Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • 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?

  • #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


    • #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


      • #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

        • 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...
          Yesterday, 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, 04-11-2024, 12:08 PM
        0 responses
        58 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        54 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        46 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        55 views
        0 likes
        Last Post seqadmin  
        Working...
        X