string-matching

Removing an item from list matching a substring

Removing an item from list matching a substring Question: How do I remove an element from a list if it matches a substring? I have tried removing an element from a list using the pop() and enumerate method but seems like I’m missing a few contiguous items that needs to be removed: sents = [‘@$tthis …

Total answers: 3

Check if string matches pattern

Check if string matches pattern Question: How do I check if a string matches this pattern? Uppercase letter, number(s), uppercase letter, number(s)… Example, These would match: A1B2 B10L1 C1N200J1 These wouldn’t (‘^’ points to problem) a1B2 ^ A10B ^ AB400 ^ Asked By: DanielTA || Source Answers: import re pattern = re.compile("^([A-Z][0-9]+)+$") pattern.match(string) Answered By: …

Total answers: 9

Search for string allowing for one mismatch in any location of the string

Search for string allowing for one mismatch in any location of the string Question: I am working with DNA sequences of length 25 (see examples below). I have a list of 230,000 and need to look for each sequence in the entire genome (toxoplasma gondii parasite). I am not sure how large the genome is, …

Total answers: 14