javascript - Splitting Nucleotide Sequences in JS with Regexp -


I am trying to divide the nucleotide sequence into amino acid strings using a regular expression. I have to start a new string in every incident of string "ATG", but I do not really want to stop the first match on "ATG". There is no order of a string of valid inputs S, CS, GS, and SS. For example, the input string has been given: ATGAACATAGGACATGAGGAGTCA I should get two strings: ATGAACATAGGACATGAGAGTCA (full point) and ATGAGATCA (Next of the first match of "ATG") a string in which "ATG" should be the result of N bar, not result.

I thought that expression / (?: [ACGT] *) (ATG) [ACGT] * / G will work, but it does not work. If it can not be done with a regexp, then just writing the code is quite easy, but I always like an elegant solution if someone is available. If you really want to use regular expressions, try:

  var str = "ATGAACATAGGACATGAGGTCA"  
, Again = /ATG.* / g, matches, matches = []; while ((match = re.xac!)! == faucet) {matches.push (match); Re.lastIndex = match.index + 3;}

But be careful with exec and you can easily make it an infinite loop to change the index.

Otherwise, by using the indexOf you get the substrings to index and substr When: ((Offset = Match. Index of ("ATG", offset) gt;:

  var str = "ATGAACATAGGACATGAGAGTCA", offset = 0, match = str, matches = []; ; -1) {match = match.Substr (offset); matches.push (match); offset + = 3;}  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -