Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • AnushaC
    Member
    • Sep 2013
    • 78

    regex.match in python

    Dear All,

    I want to search a substring in a string allow certain number of mismateches

    I have two strings

    >>> S1
    'ATAGCACTGC'
    >>> S2
    'ACAGCATTGC'

    I want to allow 2 mismatches in this case and I mean to say if it has 2 mismatches, it should say strings are matched and want to know what indexes mismatches there and what are those mismatches


    >>> regex.match('(ATAGCACTGC){e<=2}', 'ACAGCATTGC')
    <regex.Match object; span=(0, 10), match='ACAGCATTGC', fuzzy_counts=(2, 0, 0)>

    is working

    but if give S1 or S2 instead of actual string it is not working

    regex.match(S1 + '{e<=2}',S2)
    regex.match(S1'{e<=2}',S2) etc all are giving syntax errors


    Thanks,
    Anusha
  • wolma
    Member
    • May 2014
    • 23

    #2
    regex.match(S1 + '{e<=2}',S2)

    You are missing parentheses - () - around S1.
    Beyond that you seem to be using a VERY outdated version of Python, if that's the stdlib's regex module in your example. It's really time for an upgrade.

    Comment

    • liruiradiant
      Junior Member
      • Apr 2013
      • 4

      #3
      Python3.5

      Is there a equivalent function in python3.5 for

      Code:
      regex.match(S1 + '{e<=2}',S2)
      I only find `re` and https://github.com/seatgeek/fuzzywuzzy

      Excuse me for posting on a old post

      Thanks!

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Cancer Drug Resistance: The Lingering Barrier to Rising Survival
        by SEQadmin2



        Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

        There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
        Today, 05:17 AM
      • GATTACAT
        Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
        by GATTACAT
        Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
        07-01-2026, 11:43 AM
      • SEQadmin2
        Nine Things a Sample Prep Scientist Thinks About Before Sequencing
        by SEQadmin2


        I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

        Here are nine questions we think about, in roughly the order they matter, before...
        06-18-2026, 07:11 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, Yesterday, 11:05 AM
      0 responses
      7 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-02-2026, 11:08 AM
      0 responses
      29 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-30-2026, 05:37 AM
      0 responses
      28 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 06-26-2026, 11:10 AM
      0 responses
      27 views
      0 reactions
      Last Post SEQadmin2  
      Working...