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
          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
        • seqadmin
          Strategies for Sequencing Challenging Samples
          by seqadmin


          Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
          03-22-2024, 06:39 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 04-11-2024, 12:08 PM
        0 responses
        30 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 10:19 PM
        0 responses
        32 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-10-2024, 09:21 AM
        0 responses
        28 views
        0 likes
        Last Post seqadmin  
        Started by seqadmin, 04-04-2024, 09:00 AM
        0 responses
        52 views
        0 likes
        Last Post seqadmin  
        Working...
        X