​
UPDATE VII
​
The bp error calculation in vwdcCore was corrected to account for missing letters due to letter substitutions.
​
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[{},{},"",helpTrue];​​
Variable Width Discrete Correlation, version 10/8/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", parallelProcesses0, parallelDepth0, chattyFalse, helpFalse]
• 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 parallelDepth0.
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 parallelProcessors0.
1 will parallelize target processing.
2 will parallelize query processing.
3 will parallelize regex processing.
• chattyTrue will make the program verbose, supplying information on options and computations.
• helpTrue displays this text.
TEST PROGRAM
In[]:=
myTargets={​​StringJoin[​​RandomChoice[{"A","T","C","G"},1023],​​"ATGTTATAGTTGAGTGAGGATAA",​​RandomChoice[{"A","T","C","G"},1023],​​"ATGTTGTAGTTGAGTGAGGATAA",​​RandomChoice[{"A","T","C","G"},1023],​​"ATGTTGGTTGAGTGAGGATAA",​​RandomChoice[{"A","T","C","G"},1023],​​"ATGTTTTTATAGTTGAGTGAGGATAA",​​RandomChoice[{"A","T","C","G"},1023]​​]&[SeedRandom[4313]],​​StringJoin[​​RandomChoice[{"A","T","C","G"},1023],​​"TTGTCCGTTTCTTATACAAT",​​RandomChoice[{"A","T","C","G"},1023],​​"TTGTCAGTTTCTTATACAAT",​​RandomChoice[{"A","T","C","G"},1023],​​"TTGTCATTTCTTATACAAT",​​RandomChoice[{"A","T","C","G"},1023],​​"TTGTCAAAGTTTCTTATACAAT",​​RandomChoice[{"A","T","C","G"},1023]​​]&[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,targetLabelsmyTargetLabels,queryLabelsmyQueryLabels,resultFilemyResultFile,parallelProcesses0,parallelDepth0,chattyFalse,helpFalse];​​finishTime=AbsoluteTime[];​​Print["elapsed time = ",ElapsedTimeStr[finishTime-startTime]];​​If[ToString[Head[myResultFile]]≠"File",​​Print[Grid[result,Alignment->Left,Frame->All,FrameStyle->Gray]]​​];​​
elapsed time = 2.69 seconds
target
query
errors
subsequence
position
random 4313
LMFC26 F
0
ATGTTATAGTTGAGTGAGGATAA
{1024,1046}
random 9639
LMFC30 F
0
TTGTCCGTTTCTTATACAAT
{1024,1043}
random 4313
LMFC26 F
1
ATGTTGTAGTTGAGTGAGGATAA
{2070,2092}
random 9639
LMFC30 F
1
TTGTCAGTTTCTTATACAAT
{2067,2086}
random 4313
LMFC26 F
2
TTTTATAGTTGAGTGAGGATAA
{4164,4185}
random 9639
LMFC30 F
2
TTGTCATTTCTTATACAAT
{3110,3128}
random 4313
LMFC26 F
3
ATGTTGGTTGAGTGAGGATAA
{3116,3136}
random 9639
LMFC30 F
3
TTGTCAAAGTTTCTTATACAAT
{4152,4173}