overlapping-matches

Collapse a list of range tuples into the overlapping ranges

不问归期 提交于 2021-02-07 03:36:53
问题 I'm looking for the most memory efficient way to solve this problem. I have a list of tuples representing partial string matches in a sentence: [(0, 2), (1, 2), (0, 4), (2,6), (23, 2), (22, 6), (26, 2), (26, 2), (26, 2)] The first value of each tuple is the start position for the match, the second value is the length. The idea is to collapse the list so that only the longest continue string match is reported. In this case it would be: [(0,4), (2,6), (22,6)] I do not want just the longest

Collapse a list of range tuples into the overlapping ranges

≯℡__Kan透↙ 提交于 2021-02-07 03:35:33
问题 I'm looking for the most memory efficient way to solve this problem. I have a list of tuples representing partial string matches in a sentence: [(0, 2), (1, 2), (0, 4), (2,6), (23, 2), (22, 6), (26, 2), (26, 2), (26, 2)] The first value of each tuple is the start position for the match, the second value is the length. The idea is to collapse the list so that only the longest continue string match is reported. In this case it would be: [(0,4), (2,6), (22,6)] I do not want just the longest

How do I find all overlapping matches of variable size? [duplicate]

此生再无相见时 提交于 2021-01-28 09:34:32
问题 This question already has answers here : How to get all overlapping matches in python regex that may start at the same location in a string? (2 answers) Closed 1 year ago . I want to find all the substrings of '01' that contain a digit or more using a regex, i.e. I want to get (in whatever order): ['0', '01', '1'] The problem is that regex matches don't usually pick out overlapping substrings: >>> re.findall(r'\d+', '01') ['01'] A clever workaround (found here) involves using a lookahead. But

How do I find all overlapping matches of variable size? [duplicate]

天涯浪子 提交于 2021-01-28 09:33:29
问题 This question already has answers here : How to get all overlapping matches in python regex that may start at the same location in a string? (2 answers) Closed 1 year ago . I want to find all the substrings of '01' that contain a digit or more using a regex, i.e. I want to get (in whatever order): ['0', '01', '1'] The problem is that regex matches don't usually pick out overlapping substrings: >>> re.findall(r'\d+', '01') ['01'] A clever workaround (found here) involves using a lookahead. But

Subset only those rows whose intervals does not fall within another data.frame

守給你的承諾、 提交于 2020-01-15 12:49:10
问题 How can i compare two data frames (test and control) of unequal length, and remove the row from test based on three criteria, i) if the test$chr == control$chr ii) test$start and test$end lies with in the range of control$start and control$end iii) test$CNA and control$CNA are same. test = R_level logp chr start end CNA Gene 2 7.079 11 1159 1360 gain Recl,Bcl 11 2.4 12 6335 6345 loss Pekg 3 19 13 7180 7229 loss Sox1 control = R_level logp chr start end CNA Gene 2 5.9 11 1100 1400 gain Recl

Overlapping regex matches

若如初见. 提交于 2019-12-18 09:31:27
问题 I'm trying to create the following regular expression: return a string between AUG and ( UAG or UGA or UAA ) from a following RNA string: AGCCAUGUAGCUAACUCAGGUUACAUGGGGAUGACCCCGCGACUUGGAUUAGAGUCUCUUUUGGAAUAAGCCUGAAUGAUCCGAGUAGCAUCUCAG , so that all matches would be found, including the overlapping ones. I've tried several regexes, ending up with something like that: matches = re.findall('(?=AUG)(\w+)(?=UAG|UGA|UAA)',

Find overlapping dates for each ID and create a new row for the overlap

百般思念 提交于 2019-12-18 02:57:25
问题 I would like to find the overlapping dates for each ID and create a new row with the overlapping dates and also combine the characters (char) for the lines. It is possible that my data will have >2 overlaps and need >2 combinations of characters. eg. ERM Data: ID date1 date2 char 15 2003-04-05 2003-05-06 E 15 2003-04-20 2003-06-20 R 16 2001-01-02 2002-03-04 M 17 2003-03-05 2007-02-22 I 17 2005-04-15 2014-05-19 C 17 2007-05-15 2008-02-05 I 17 2008-02-05 2012-02-14 M 17 2010-06-07 2011-02-14 V

How to render multiple markers at the exact same coordinates in Google Maps API?

五迷三道 提交于 2019-12-11 03:00:59
问题 I have multiple addresses on the same street with the same house number, but with different apartment numbers. Google Maps Geocoding Service (v2) doesn't go down to apartment level accuracy for many addresses and just returned me the exact same geocode coordinates for them. So the problem is that when I go to display them, only one pushpin shows up no matter how much you zoom in. And my question is; what is a good way to render multiple pushpins at the exact same house address? I've seen how

Regex split into overlapping strings

房东的猫 提交于 2019-12-04 13:59:13
问题 I'm exploring the power of regular expressions, so I'm just wondering if something like this is possible: public class StringSplit { public static void main(String args[]) { System.out.println( java.util.Arrays.deepToString( "12345".split(INSERT_REGEX_HERE) ) ); // prints "[12, 23, 34, 45]" } } If possible, then simply provide the regex (and preemptively some explanation on how it works). If it's only possible in some regex flavors other than Java, then feel free to provide those as well. If

Overlapping matches with finditer() in Python

时光毁灭记忆、已成空白 提交于 2019-12-02 06:21:13
问题 I'm using a regex to match Bible verse references in a text. The current regex is REF_REGEX = re.compile(''' (?<!\w) # Not preceded by any words (?P<quote>q(?:uote)?\s+)? # Match optional 'q' or 'quote' followed by many spaces (?P<book> (?:(?:[1-3]|I{1,3})\s*)? # Match an optional arabic or roman number between 1 and 3. [A-Za-z]+ # Match any alphabetics )\.? # Followed by an optional dot (?: \s*(?P<chapter>\d+) # Match the chapter number (?: [:\.](?P<startverse>\d+) # Match the starting verse