public static void Main(String[] args) { String connectionString = @"Persist Security Info=False;User ID=pathcase;Password=dblab;Initial Catalog=polyposisdb_large3;Data Source=127.0.0.1;"; Database db = new Database(connectionString); //open the database db.OpenConnection(); if (args[0] == "label") { int PedigreeID = Convert.ToInt32(args[1]); EGDL egdl = new EGDL(db); DateTime start = DateTime.Now; egdl.EGDLEncoding(PedigreeID); TimeSpan time = DateTime.Now.Subtract(start); Console.WriteLine(time.TotalMilliseconds + " ms"); Console.WriteLine("Finished!"); } else if (args[0] == "average_inbreeding") { int PedigreeID = Convert.ToInt32(args[1]); InbreedingCalculation ic = new InbreedingCalculation(db, PedigreeID); double t = ic.AverageIC(); Console.WriteLine("Inbreeding Coefficient: " + t); } else if (args[0] == "average_nc") { int PedigreeID = Convert.ToInt32(args[1]); InbreedingCalculation ic = new InbreedingCalculation(db, PedigreeID); double t = ic.AverageICNC(); Console.WriteLine("Inbreeding Coefficient: " + t); } else if (args[0] == "test") { int PedigreeID = Convert.ToInt32(args[1]); InbreedingCalculation ic = new InbreedingCalculation(db, 0); Console.WriteLine(ic.CalculateNC(",1,1", "#,1#.0.0#,1,0#.0.0.0%.0.0.0%,1,1")); } //Console.Read(); //close the database db.CloseConnection(); }
/// <summary> /// The constructor /// </summary> /// <param name="individualEGDL">The EGDL code of an individual</param> /// <param name="db">The database connection</param> public InbreedingCalculation(Database db, int PedigreeID) { localGraph = new Graph(db); currentPedigree = PedigreeID; egdls = null; }
/// <summary> /// The graph is stored in the database, so the /// input parameter of the constructor is an instance of the database /// </summary> /// <param name="conn">A databse instance</param> public Graph(Database conn) { db = conn; }
/// <summary> /// The constructor of EGDL class uses a database instance as its input parameter. /// The reason is that we have to access to the databse frequently, and it's better to open the /// database once, do all the tasks and then close it. /// </summary> /// <param name="conn">The connection string of the database</param> public EGDL(Database conn) { //using the database conn to initilize the local graph object localGraph = new Graph(conn); }