FOURTH UPDATE
Here is the orderedPartsCalc code. I got a lot of mileage out of SequenceAlignment.
Next update will have entire VWDC function.
Here is the orderedPartsCalc code. I got a lot of mileage out of SequenceAlignment.
Next update will have entire VWDC function.
(*orderedPartsCalc*)(*exampledata*)(*GCA_009761775.1chromosome4*)chrSequence=Import["C:\\Users\\tange\\Documents\\Compositions\\SequenceTools Quest\\Mathematica\\chr04.txt"];chrSequenceBp=StringLength[chrSequence];regexSpec={"T.{20,20}T",{4,2},{1,0,-1},"TTGTCCGTTTCTTATACAAT",20};(*LMFC30F*)regex=regexSpec[[1]];positions=StringPosition[chrSequence,RegularExpression[regex]];positionsCount=Length[positions];(*calculation*)startTime=AbsoluteTime[];g=1;(*forGatherBy*)vettedCandidates=SortBy[((SortBy[#,({#[[1]],#[[3]]}&)][[1,1;;3]])&/@GatherBy[(Join[{{#[[1,1,1]],#[[1,1,2]],#[[1,1,3]],g}},Table[{#[[1,c,1]],#[[1,c,2]],#[[1,c,3]],If[#[[1,c-1,3,1]]≤#[[1,c,3,1]]≤#[[1,c-1,3,2]],g,++g]},{c,2,#[[2]]}]]&[{#,Length[#]}&[Table[(If[#[[1]]≤regexSpec[[2,1]],{#[[1]],#[[2]],pos},Nothing])&[{regexSpec[[5]]-Total[(StringLength[#]&/@#[[1]])],#[[2]]}&[{(If[StringQ[#],#,Nothing]&/@#[[1]]),#[[2]]}&[{SequenceAlignment[regexSpec[[4]],#],#}&[StringTake[chrSequence,pos]]]]],{pos,positions}]]]),Last]),({#[[1]],#[[3]]}&)];positions=Null;chrSequence=Null;vettedCandidatesCount=Length[vettedCandidates];finishTime=AbsoluteTime[];(*stats*)Print["OUTPUT"];Print["chrSequence ~ ",chrSequenceBp," bp"];Print["primer = ",regexSpec[[4]]];Print["regex = ",regex];Print["positionsCount = ",positionsCount];Print["vettedCandidatesCount = ",vettedCandidatesCount];Print["elapsed time = ",SetPrecision[finishTime-startTime,3]," sec"];Print["positions / sec = ",Round[positionsCount/(finishTime-startTime),0.1]];Print["vettedCandidates , candidate, position:"];Print[vettedCandidates[[1;;7]]//Column];Print["⋯"];Print[vettedCandidates[[-7;;-1]]//Column];
ϵ
bp
OUTPUT
chrSequence ~ 14823915 bp
primer = TTGTCCGTTTCTTATACAAT
regex = T.{20,20}T
positionsCount = 1710145
vettedCandidatesCount = 17184
elapsed time = 46.1 sec
positions / sec = 37088.5
vettedCandidates , candidate, position:
ϵ
bp
{1,TTGCTCGTATTCTTATACTAAT,{4090303,4090324}} |
{1,TTGTCCTTTCATTATACAGCAT,{4582851,4582872}} |
{2,TTGTCTCAGGTTTCTCATAAAT,{51501,51522}} |
{2,TTGTCCGATTCTCTTAGAATAT,{80969,80990}} |
{2,TTTAACAGTTTCTATATACAAT,{734871,734892}} |
{2,TTGTACTTCTTTCTTTACAACT,{1056802,1056823}} |
{2,TTTGTCCTTCTTATCATGCAAT,{1341734,1341755}} |
⋯
{4,TTGGTCAGCTATATACTACAAT,{14816944,14816965}} |
{4,TGCGATTTATTGAAATTACAAT,{14817947,14817968}} |
{4,TTTCGTATTAATATGTTACAAT,{14818176,14818197}} |
{4,TCTTTTGTCGTTGTTATTACAT,{14819260,14819281}} |
{4,TTGCACTATATTCTACTAGAAT,{14819541,14819562}} |
{4,TTTCTTTTCTTTCTTTTTAAAT,{14821786,14821807}} |
{4,TCTGTCCAAAGTTCTAACCATT,{14823383,14823404}} |