Example #1
0
    private string PrintResultTable(ICoordinateSystem fromCoordSys, ICoordinateSystem toCoordSys, ICoordinate fromPnt, ICoordinate toPnt, ICoordinate refPnt, ICoordinate backPnt, string header)
    {
        string table = "<table style=\"border: 1px solid #000; margin: 10px;\">";

        table += "<tr><td colspan=\"2\"><h3>" + header + "</h3></td></tr>";
        table += "<tr><td width=\"130px\" valign=\"top\">Input coordsys:</td><td>" + fromCoordSys.WKT + "</td></tr>";
        table += "<tr><td valign=\"top\">Output coordsys:</td><td>" + toCoordSys.WKT + "</td></tr>";
        table += "<tr><td>Input coordinate:</td><td>" + fromPnt.ToString() + "</td></tr>";
        table += "<tr><td>Ouput coordinate:</td><td>" + toPnt.ToString() + "</td></tr>";
        table += "<tr><td>Expected coordinate:</td><td>" + refPnt.ToString() + "</td></tr>";
        //table += "<tr><td>Difference:</td><td>" + (refPnt - toPnt).ToString() + "</td></tr>";
        table += "<tr><td>Reverse transform:</td><td>" + backPnt.ToString() + "</td></tr>";
        //table += "<tr><td>Difference:</td><td>" + (backPnt - fromPnt).ToString() + "</td></tr>";
        table += "</table>";
        return(table);
    }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return("NODE: " + pt.ToString() + ": " + Degree);
 }
        public static Tuple <List <ICoordinate>, List <bool> > RandomizeCoordinatesAndSave(int numcoords, bool save = true)
        {
            List <ICoordinate> coordinates = new List <ICoordinate>();
            List <bool>        labels      = new List <bool>();
            bool instance_created          = false;

            while (!instance_created)
            {
                if ((Config.ActionList & Actions.Instance_Uniform) != 0)
                {
                    for (var i = 0; i < numcoords; i++)
                    {
                        if (StaticConfigParams.RandomInstanceType == typeof(Coordinate))
                        {
                            coordinates.Add(Coordinate.MakeRandom());
                        }
                        else if (StaticConfigParams.RandomInstanceType == typeof(Coordinate3D))
                        {
                            coordinates.Add(Coordinate3D.MakeRandom());
                        }
                        labels.Add(StaticConfigParams.rnd.NextDouble() > StaticConfigParams.CONST_NEGATIVELABELRATE);
                    }
                }
                if ((Config.ActionList & Actions.Instance_PlantedSingleEnrichment) != 0)
                {
                    for (var i = 0; i < numcoords; i++)
                    {
                        if (StaticConfigParams.RandomInstanceType == typeof(Coordinate))
                        {
                            coordinates.Add(Coordinate.MakeRandom());
                        }
                        else if (StaticConfigParams.RandomInstanceType == typeof(Coordinate3D))
                        {
                            coordinates.Add(Coordinate3D.MakeRandom());
                        }
                    }
                    ICoordinate pivotCoord = null;
                    if (StaticConfigParams.RandomInstanceType == typeof(Coordinate))
                    {
                        pivotCoord = Coordinate.MakeRandom();
                    }
                    else if (StaticConfigParams.RandomInstanceType == typeof(Coordinate3D))
                    {
                        pivotCoord = Coordinate3D.MakeRandom();
                    }

                    var prPos = (int)Math.Round((1.0 - StaticConfigParams.CONST_NEGATIVELABELRATE) * numcoords);
                    mHGJumper.Initialize(prPos, numcoords - prPos);
                    coordinates = coordinates.OrderBy(t => t.EuclideanDistance(pivotCoord)).ToList();
                    labels      = mHGJumper.SampleSignificantEnrichmentVector(1e-3).ToList();
                    Console.WriteLine($"Instantiated sample with p={mHGJumper.minimumHypergeometric(labels.ToArray()).Item1:e} around pivot {pivotCoord.ToString()}");
                    mHGJumper.optHGT = 0.05;
                }
                instance_created = labels.Any();
            }
            if (save)
            {
                Generics.SaveToCSV(coordinates.Zip(labels, (a, b) => a.ToString() + "," + Convert.ToDouble(b)),
                                   $@"coords_{StaticConfigParams.filenamesuffix}.csv", true);
            }
            return(new Tuple <List <ICoordinate>, List <bool> >(coordinates, labels));
        }
Example #4
0
 private string PrintResultTable(ICoordinateSystem fromCoordSys, ICoordinateSystem toCoordSys, ICoordinate fromPnt, ICoordinate toPnt, ICoordinate refPnt, ICoordinate backPnt, string header)
 {
     string table = "<table style=\"border: 1px solid #000; margin: 10px;\">";
     table += "<tr><td colspan=\"2\"><h3>" + header + "</h3></td></tr>";
     table += "<tr><td width=\"130px\" valign=\"top\">Input coordsys:</td><td>" + fromCoordSys.WKT + "</td></tr>";
     table += "<tr><td valign=\"top\">Output coordsys:</td><td>" + toCoordSys.WKT + "</td></tr>";
     table += "<tr><td>Input coordinate:</td><td>" + fromPnt.ToString() + "</td></tr>";
     table += "<tr><td>Ouput coordinate:</td><td>" + toPnt.ToString() + "</td></tr>";
     table += "<tr><td>Expected coordinate:</td><td>" + refPnt.ToString() + "</td></tr>";
     //table += "<tr><td>Difference:</td><td>" + (refPnt - toPnt).ToString() + "</td></tr>";
     table += "<tr><td>Reverse transform:</td><td>" + backPnt.ToString() + "</td></tr>";
     //table += "<tr><td>Difference:</td><td>" + (backPnt - fromPnt).ToString() + "</td></tr>";
     table += "</table>";
     return table;
 }