SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
Proper regex to mark duplicates using Picard tools on SOLiD data anibhax Bioinformatics 0 12-04-2014 07:04 AM
Regex Searches? anzdro General 2 07-18-2013 01:49 PM
HTSeq for python 3 schroedj Bioinformatics 0 07-15-2013 02:38 PM
Python marqudiego General 4 06-30-2013 11:14 PM
python dror Bioinformatics 0 11-29-2010 04:22 AM

Reply
 
Thread Tools
Old 10-29-2015, 02:04 PM   #1
AnushaC
Member
 
Location: San Diego

Join Date: Sep 2013
Posts: 78
Default 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
AnushaC is offline   Reply With Quote
Old 10-29-2015, 02:40 PM   #2
wolma
Member
 
Location: Germany

Join Date: May 2014
Posts: 23
Default

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.
wolma is offline   Reply With Quote
Old 03-18-2019, 07:36 AM   #3
liruiradiant
Junior Member
 
Location: Washington State

Join Date: Apr 2013
Posts: 4
Default 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!
liruiradiant is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 05:26 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO