Scott's Data Management Robot

This notebook contains, "Scott's Robot", described in http://katlas.math.toronto.edu/wiki/Modifying_Knot_Pages...

After downloading it, KnotTheory` and WikiLink.m, it takes five steps to run Scott's Robot:
1. Set the KnotTheory` directory and load KnotTheory`.
2. Set the WikiLink directory and load WikiLink.m.
3. Create the WikiLink connection to the Knot Atlas wiki server.
4. Load ManagingKnotData.m and retrieve the "Invariant Definition Table"
5. Upload some data!

1. Set the KnotTheory` directory and load KnotTheory`.

Change "KnotAtlasPath" as appropriate for your system (e.g., it should be the directory above "KnotTheory/") and execute the following cell:

Dror's version

KnotAtlasPath  =  "C:/drorbn/KAtlas/";
AppendTo[$Path,  KnotAtlasPath];
<<  KnotTheory`
<<  KnotTheoryExtra`

Scott's version

\(\(KnotAtlasPath\  = \ "c:\scott\math.berkeley.edu\Work\Mathematica\KnotAtlas\";\)\)
AppendTo[$Path,  KnotAtlasPath];
<<  KnotTheory`
<<  KnotTheoryExtra`

2. Set the WikiLink directory and load WikiLink.m.

Change "WikiLinkPath" as appropriate for your system (i.e., it should be the directory where WikiLink.m resides) and execute the following cell:

WikiLinkPath  =  
        KnotAtlasPath <> "WikiLink\\";
Get[WikiLinkPath <> "WikiLink.m"];
SetJarPath[WikiLinkPath];

3. Create the WikiLink connection to the Knot Atlas wiki server.

Execute the cell below. You will be prompted for your username and password on the Knot Atlas wiki.

\(CreateWikiConnection[
"http://katlas.math.toronto.edu/w/index.php", 
InputString["Enter Your Username:"], 
InputString["Enter Your Password"]
]\)

WikiUserName[]

4. Load ManagingKnotData.m and retrieve the "Invariant Definition Table"

ManagingKnotDataPath = 
        KnotAtlasPath <> "maintenance\\";
Get[ManagingKnotDataPath <> "ManagingKnotData.m"];

LoadInvariantRules["Invariant_Definition_Table"];

5. Upload some data!

data1 = 
      RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
        AllKnots[{0, 5}], "KnotTheory"]

StoreInvariants[data1, "KnotAtlas"]

FindDataDiscrepancies[Invariants["KnotTheory` Knot Invariants"], 
      AllKnots[0], "KnotTheory", "KnotAtlas"]

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[{0, 6}], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[7], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[8], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[9], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[10], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Knot Invariants"], 
          AllKnots[11], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Link Invariants"], 
          AllLinks[{1, 5}], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

StoreInvariants[
        RetrieveInvariants[Invariants["KnotTheory` Link Invariants"], 
          AllLinks[], "KnotTheory"], "KnotAtlas"] // 
      AbsoluteTiming

Further examples

RetrieveInvariant["Next Knot", 
      Knot[10, 20], "KnotTheory"]

RetrieveInvariants[{"Next Knot", "Previous Knot"}, {Knot[10, 
          20], Knot[10, 21]}, "KnotTheory"]

RetrieveInvariant["Next Knot", 
      Knot[10, 20], "KnotAtlas"]

RetrieveInvariant["Next Knott", 
      Knot[10, 20], "KnotAtlas"]

RetrieveInvariants[{"Next Knot", "Previous Knot"}, {Knot[10, 
          20], Knot[10, 21]}, "KnotAtlas"]

data = 
      RetrieveInvariants[Invariants["Navigation"], 
        AllKnots[{0, 4}], "KnotTheory"]

StoreInvariants[data, "KnotAtlas", Write -> False]

StoreInvariants[data, "KnotAtlas"]

Now we'll simulate a vandal, and use FindDataDiscrepancies to reveal the problem.

realData = 
      RetrieveInvariants[{"Next Knot"}, {Knot[10, 
            20]}, "KnotTheory"]

Make some fake data instead

fakeData = {{"Next Knot", Knot[10, 20], 
            Knot[10, 22]}};

StoreInvariants[fakeData, "KnotAtlas"]

RetrieveInvariants[{"Next Knot"}, {Knot[10, 
          20]}, "KnotAtlas"]

Mwhahaha! Our virtual vandal has succeeded to putting erroneous data in the Knot Atlas. However, now it's easy to catch!

FindDataDiscrepancies[{"Next Knot"}, {Knot[10, 
          20]}, "KnotTheory", "KnotAtlas"]

Now clean up our mess!

StoreInvariants[realData, "KnotAtlas"]