UPDATE VI
A new option “parallelDepth” is available.
parallelDepth0 will prohibit parallelization.
1 will parallelize target processing.
2 will parallelize query processing.
3 will parallelize regex processing.
UPDATE VI
A new option “parallelDepth” is available.
parallelDepth0 will prohibit parallelization.
1 will parallelize target processing.
2 will parallelize query processing.
3 will parallelize regex processing.
FUNCTIONS
In[]:=
MACROS
In[]:=
Remove[ElapsedTimeStr];ElapsedTimeStr[esec_]:=Which[esec<60,ToString[SetPrecision[esec,3]]<>" seconds",esec<60*60,ToString[SetPrecision[esec/60.,3]]<>" minutes",True,ToString[SetPrecision[esec/(60*60.),3]]<>" hours"];
EXAMPLE HELP USAGE
In[]:=
VWDC[{},{},"",helpTrue];
Variable Width Discrete Correlation, version 9/20/2024.
This function seeks exact and nearly exact matches of String subsequences in larger String sequences.
The subsequences are termed "queries" and the larger sequences are termed "targets".
The amount of acceptable error is controlled by option "eAccept".
Minimal execution:
VWDC[targets, queries, workingDirectory]
• targets must be a list of one or more String or existing File entities containing a String.
for example, they could be a chromosome sequence or subsequence.
• queries must be a list of one or more String entities to search for in the targets.
for example, they could be molecular markers, gene subsequences, etc.
• workingDirectory must be an existing (possibly empty) Directory path.
for example, FileNameJoin[{NotebookDirectory[],"vwdc tmp"}].
simultaneous execution of VWDC with the same workingDirectory is not recommended.
The minimal execution will write file "VWDC result.mx" to the workingDirectory.
Default options and alternatives:
VWDC[targets, queries, workingDirectory, targetLabels"Automatic", queryLabels"Automatic", eAccept"Automatic", resultFile"Automatic", parallelProcesses0, parallelDepth0, chattyFalse, helpFalse]
• targetLabels must either be "Automatic" or a List of String(s).
the number of labels must match the number of targets.
• queryLabels must either be "Automatic" or a List of String(s).
the number of labels must match the number of queries.
• eAccept must either be "Automatic" or an Integer ≥ 0.
it specifies the number of acceptable letter errors in a search.
"Automatic" will select a value appropriate for molecular markers.
an integer value will apply to all query searches.
zero returns exact query matches, which is faster by direct string search.
• resultFile must be None or "Automatic" or a valid File specification.
None causes VWDC to return a Table of values, e.g. result=VWDC[... .
"Automatic" will write the Table to "VWDC result.mx" in the workingDirectory.
anything else must be type File — choose file extensions appropriate for Table.
• parallelProcessors must be an integer either = 0 or > 1.
0 is synonymous with parallelDepth0.
values p > 0 will attempt to launch p parallel kernels — which may be limited by your license.
targets less than 80kB in length will likely not benefit from values > 0 in the current version.
targets less than 40kB in length can experience longer run times from values > 0.
• parallelDepth must be 0, 1, 2, or 3.
0 is synonymous with parallelProcessors0.
1 will parallelize target processing.
2 will parallelize query processing.
3 will parallelize regex processing.
• chattyTrue will make the program verbose, supplying information on options and computations.
• helpTrue displays this text.
TEST PROGRAM
In[]:=
myTargets={StringJoin[RandomChoice[{"A","T","C","G"},4095]]&[SeedRandom[4313]],StringJoin[RandomChoice[{"A","T","C","G"},4095]]&[SeedRandom[9639]]};myTargetLabels={"random 4313","random 9639"};myQueries={"ATGTTATAGTTGAGTGAGGATAA","TTGTCCGTTTCTTATACAAT"};myQueryLabels={"LMFC26 F","LMFC30 F"};myWorkDir=FileNameJoin[{NotebookDirectory[],"vwdc tmp"}];(*mustexist*)myResultFile=None;(*File[FileNameJoin[{NotebookDirectory[],StringRiffle[myTargetLabels,", "]<>"; "<>StringRiffle[myQueryLabels,", "]<>" test.tsv"}]];*)startTime=AbsoluteTime[];result=VWDC[myTargets,myQueries,myWorkDir,targetLabelsmyTargetLabels,queryLabelsmyQueryLabels,resultFilemyResultFile,parallelProcesses0,parallelDepth0,chattyTrue,helpFalse];finishTime=AbsoluteTime[];Print["elapsed time = ",ElapsedTimeStr[finishTime-startTime]];If[ToString[Head[myResultFile]]≠"File",Print[Grid[result,Alignment->Left,Frame->All,FrameStyle->Gray]]];
VWDC (Sun 22 Sep 2024 5:47pm):
Arguments:
targetsCount = 2
targets type String = 2
targets type File = 0
queriesCount = 2
workingDirectory = C:\Users\tange\Documents\Mathematica Projects\VWDC\Mathematica\vwdc tmp
Options:
chatty = True (True | False)
targetLabels = {random 4313,random 9639} ("Automatic" | List)
queryLabels = {LMFC26 F,LMFC30 F} ("Automatic" | List)
eAccept = Automatic ("Automatic" | Integer ≥ 0)
resultFile = None ("Automatic" | File | None - returns possibly large Table)
parallelProcesses = 0 (0 | 2 | 3 | …)
parallelDepth = 0 (0 | 1 | 2 | 3)
help = False (True | False)
Computed Options:
ϵAcceptValues = {4,5}
Computations:
parallelDepthOption = 0
processing "random 4313" (4095 bp)
processing "LMFC26 F" (23 bp)
ϵAccept = 5
multiplexerSpecs = {{6,-7,-1},{5,-5}} … (61)
regexSpecifications = {A.{16,16}A,{5,-5},{6,-7,-1},ATGTTATAGTTGAGTGAGGATAA,23,C:\Users\tange\Documents\Mathematica Projects\VWDC\Mathematica\vwdc tmp\parallel vwdc tmp 1.mx} … (61)
sequentialLengthStats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,6,0,0,1,0,4,0,0,8,0,0,1,6,5,6,4,8,8}
sequentialLengthStats count = 61
sequentialLengthStats total = 61
processing "LMFC30 F" (20 bp)
ϵAccept = 4
multiplexerSpecs = {{5,-6,-1},{4,-4}} … (41)
regexSpecifications = {C.{14,14}T,{4,-4},{5,-6,-1},TTGTCCGTTTCTTATACAAT,20,C:\Users\tange\Documents\Mathematica Projects\VWDC\Mathematica\vwdc tmp\parallel vwdc tmp 1.mx} … (41)
sequentialLengthStats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,4,0,1,2,1,6,0,1,1,6,4,1,4}
sequentialLengthStats count = 41
sequentialLengthStats total = 32
targetTableDA Length = 23
processing "random 9639" (4095 bp)
processing "LMFC26 F" (23 bp)
ϵAccept = 5
multiplexerSpecs = {{6,-7,-1},{5,-5}} … (61)
regexSpecifications = {A.{16,16}A,{5,-5},{6,-7,-1},ATGTTATAGTTGAGTGAGGATAA,23,C:\Users\tange\Documents\Mathematica Projects\VWDC\Mathematica\vwdc tmp\parallel vwdc tmp 1.mx} … (61)
sequentialLengthStats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,2,1,1,4,5,1,0,10,2,1,4,2,5,4,2,8,4,4,5,10,5,10,5,8,8}
sequentialLengthStats count = 61
sequentialLengthStats total = 112
processing "LMFC30 F" (20 bp)
ϵAccept = 4
multiplexerSpecs = {{5,-6,-1},{4,-4}} … (41)
regexSpecifications = {C.{14,14}T,{4,-4},{5,-6,-1},TTGTCCGTTTCTTATACAAT,20,C:\Users\tange\Documents\Mathematica Projects\VWDC\Mathematica\vwdc tmp\parallel vwdc tmp 1.mx} … (41)
sequentialLengthStats = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,5,2,2,1,2,5,1,2,3,5,5,3,5}
sequentialLengthStats count = 41
sequentialLengthStats total = 43
targetTableDA Length = 23
resultsTable length (w/o header) = 46
elapsed time = 1.44 seconds
target | query | errors | subsequence | position |
random 9639 | LMFC30 F | 3 | TTTTCCGTGGAATCTACTAACAAT | {1784,1807} |
random 4313 | LMFC30 F | 4 | TCGTCCGCTTTGCCTCCATCTAT | {333,355} |
random 4313 | LMFC30 F | 4 | TCGTCCTGTTTGTGACATAAAT | {1719,1740} |
random 4313 | LMFC30 F | 4 | TACGCCTTGTACTTATTAATAAT | {1754,1776} |
random 4313 | LMFC30 F | 4 | TGGTGTCTGCTCGTTTAACATAT | {2175,2197} |
random 4313 | LMFC30 F | 4 | TGCCGTGCTGGTTTGAAATCACAT | {2659,2682} |
random 4313 | LMFC30 F | 4 | TTAAGCGTCTTCCACTATACATAT | {2762,2785} |
random 4313 | LMFC30 F | 4 | TTCACGAAACCGTGGTTTATACAA | {2789,2812} |
random 4313 | LMFC30 F | 4 | TACGGTCCATTTTTTACATGGAT | {3218,3240} |
random 4313 | LMFC30 F | 4 | TCTCGTCACGTGGTCTGTTACGA | {3367,3389} |
random 9639 | LMFC26 F | 4 | AATTTCAGTATTAGTCGAGCTCATAA | {1251,1276} |
random 9639 | LMFC26 F | 4 | GGGAGTTAGATATTGAGTACGATATCA | {2601,2627} |
random 9639 | LMFC26 F | 4 | AGTCGTTATACGGAGGACCTACGAATAA | {2764,2791} |
random 9639 | LMFC26 F | 4 | AATTCTTATTTGATTGCAGCGATTTTAA | {3375,3402} |
random 9639 | LMFC30 F | 4 | TTAGAGGATTTCTACTAGCAAT | {755,776} |
random 9639 | LMFC30 F | 4 | GTATTCCAGCTCAATTCATGACAT | {1178,1201} |
random 9639 | LMFC30 F | 4 | TACACAATGTGCCGTTCAACAAT | {1231,1253} |
random 9639 | LMFC30 F | 4 | TTGACGATGATGTCTCTACCAGAT | {1599,1622} |
random 9639 | LMFC30 F | 4 | TTTGATTGCAGCGATTTTAACAA | {3383,3405} |
random 9639 | LMFC30 F | 4 | TTACAACGTTCCATCTTGCTCAAT | {3458,3481} |
random 4313 | LMFC26 F | 5 | ATGTCTTAGGCTTGAATCCAGACTCTTA | {49,76} |
random 4313 | LMFC26 F | 5 | TCTTTATATTGCTGGAGAAGGCCATATA | {124,151} |
random 4313 | LMFC26 F | 5 | AGCTCGCTGTAAGTTAGGGGGTTTATA | {472,498} |
random 4313 | LMFC26 F | 5 | AGCCCGTTTATATGGGAGTATTGCGTAA | {823,850} |
random 4313 | LMFC26 F | 5 | AGACTTACTACGTTATTTCAAGAGGTTA | {1290,1317} |
random 4313 | LMFC26 F | 5 | AGCTTCACATTGGAAACGCCTGAGGGAT | {1382,1409} |
random 4313 | LMFC26 F | 5 | ATGCTGGTGGTTGCGAGCGACTGCATAA | {1521,1548} |
random 4313 | LMFC26 F | 5 | AAGTGTCTAAGGGGTGTCATGTTAGATA | {1680,1707} |
random 4313 | LMFC26 F | 5 | TGTACTTATTAATAATGCAGATTGGAAA | {1761,1788} |
random 4313 | LMFC26 F | 5 | TAGTGTGCTTTATTCACGATTGCGATAA | {1811,1838} |
random 4313 | LMFC26 F | 5 | ATCCGTGACTAGTCCTACGCGAGCCGAT | {1948,1975} |
random 4313 | LMFC26 F | 5 | TGTATACCATTGCTTGAAGGGGTTCGAA | {2932,2959} |
random 4313 | LMFC26 F | 5 | ATTAATATCAGCTAATAGTGATCACTA | {3081,3107} |
random 4313 | LMFC26 F | 5 | ATGTATGCGTTCGTGAGCATACGGTCCA | {3199,3226} |
random 9639 | LMFC26 F | 5 | AGTCAAGTCTAATTGATTATGGAGTGA | {91,117} |
random 9639 | LMFC26 F | 5 | ATTAATGCCTATTGACGACATCGAGGAT | {213,240} |
random 9639 | LMFC26 F | 5 | TAGGCATCTAAGTTGACTGATACTGCAA | {429,456} |
random 9639 | LMFC26 F | 5 | GCAGTGCAATTATCTAGGTTTGGGACAA | {1052,1079} |
random 9639 | LMFC26 F | 5 | ATCTTTAGGCTGGACTGTTCGTGAGAAA | {1497,1524} |
random 9639 | LMFC26 F | 5 | AGCTTCAAACTTGAGTGACACTCATTGA | {1575,1602} |
random 9639 | LMFC26 F | 5 | TGTAAGGTGTAGACAGGTTGATTATACA | {2456,2483} |
random 9639 | LMFC26 F | 5 | TGCTATATGCGCTGCAAAGGAATCCTAA | {2682,2709} |
random 9639 | LMFC26 F | 5 | ATGAACTCGGACCGCTTAGCTGAGAGAT | {3020,3047} |
random 9639 | LMFC26 F | 5 | GAGTTATGTCGGGAGGTTACGGTTTTAA | {3069,3096} |
random 9639 | LMFC26 F | 5 | AATGCTCCATGTTGAGCATTGGTTTCAA | {3265,3292} |
random 9639 | LMFC26 F | 5 | GAACTTGTAAATACGTCTGAGGAACTTA | {3581,3608} |