private static Gene[] Genes( GeneAnnotationDBContext context, IReadOnlyList <Chromosome> chromosomes, IReadOnlyList <OriginType> originTypes ) { var genes = new[] { new Gene { KnownFunction = "cool function" } }; foreach (var gene in genes) { gene.GeneOriginType.Add(new GeneOriginType { Gene = gene, OriginType = originTypes[0] }); context.Gene.Add(gene); } context.SaveChanges(); return(genes); }
private static GeneVariant[] GeneVariantTable( GeneAnnotationDBContext context, Gene[] genes, ZygosityType[] zygosityTypes, VariantType[] variantTypes, CallType[] callTypes ) { var geneVariants = new[] { new GeneVariant { ZygosityType = zygosityTypes[0], VariantType = variantTypes[0], } }; foreach (var geneVariant in geneVariants) { context.GeneVariant.Add(geneVariant); } context.SaveChanges(); return(geneVariants); }
public LikeVariantLoader(GeneAnnotationDBContext context, IList <string> currentRow) { _context = context; _currentRow = currentRow; SetupTypeMap(); }
private static void InitVariantTypes(GeneAnnotationDBContext context) { BasicInit( context, VariantTypeConstants.VariantTypes ); }
private static void ClearTables(GeneAnnotationDBContext context) { var tableNames = new string[] { "annotation_literature", "annotation_gene_variant_literature", "gene_variant_literature", "literature", "annotation_gene", "annotation_gene_variant", "annotation", "symbol", "gene_location", "gene_origin_type", "origin_type", "app_user", "gene_variant", "gene_name", "gene", "human_genome_assembly", "zygosity_type", "variant_type", "call_type", "chromosome" }; foreach (var tableName in tableNames) { var sqlString = "DELETE FROM " + tableName + "; " ; context.Database.ExecuteSqlCommand(sqlString); } }
public static void Initialize(GeneAnnotationDBContext context) { var reset = Environment.GetEnvironmentVariable(GA_DB_RESET_VARIABLE_NAME); if (reset == null) { return; } if (!context.CallType.Any()) { InitCallTypes(context); } if (!context.OriginType.Any()) { InitOriginTypes(context); } if (!context.PathogenicSupportCategory.Any()) { InitPathogenicSupportCategories(context); } if (!context.VariantType.Any()) { InitVariantTypes(context); } if (!context.ZygosityType.Any()) { InitZygosityTypes(context); } }
private static void InitPathogenicSupportCategories(GeneAnnotationDBContext context) { BasicInit( context, PathogenicSupportCategoryConstants.PathogenicSupportCategories ); }
public static void Initialize(GeneAnnotationDBContext context) { context.Database.EnsureCreated(); /* * if (context.Gene.Any()) * { * // return; * } */ ClearTables(context); AppUserTable(context); var literatures = GetLiteratures(context); var chromosomes = ChromosomeTable(context); var originTypes = GetOriginTypes(context); var genes = Genes(context, chromosomes, originTypes); var geneNames = GeneNames(context, genes); var symbols = GetSymbols(context, genes); var geneLocations = GeneLocationTable(context, genes); var zygosityTypes = ZygosityTypeTable(context); var variantTypes = VariantTypeTable(context); var callTypes = CallTypeTable(context); var geneVariants = GeneVariantTable( context, genes, zygosityTypes, variantTypes, callTypes ); }
public static void InitializeDatabase(GeneAnnotationDBContext context) { context.Database.Migrate(); InitializeConstants.Initialize(context); var loadHugo = Environment.GetEnvironmentVariable("GA_DB_LOAD_HUGO"); if (loadHugo != null) { var hugoLoader = new HugoDataLoader(context, "hugo.csv.short"); hugoLoader.LoadData(); } var loadUcsc = Environment.GetEnvironmentVariable("GA_DB_LOAD_UCSC"); if (loadUcsc != null) { var ucscLoader = new UcscDataLoader(context, "ucsc.csv.short"); ucscLoader.LoadData(); } var loadLike = Environment.GetEnvironmentVariable("GA_DB_LOAD_LIKE"); if (loadLike != null) { var likeLoader = new LikeDataLoader(context, "like.csv.short"); likeLoader.LoadData(); } }
private static CallType[] CallTypeTable(GeneAnnotationDBContext context) { var callTypes = new[] { new CallType { Name = "VOUS" }, new CallType { Name = "Likely pathogenic" }, new CallType { Name = "Pathogenic" }, new CallType { Name = "Benign" }, new CallType { Name = "autosomal recessive carrier" } }; foreach (var callType in callTypes) { context.CallType.Add(callType); } context.SaveChanges(); return(callTypes); }
/// <inheritdoc /> public static void InitializeDatabase(GeneAnnotationDBContext context) { //DbInitializer.Initialize(context); context.Database.OpenConnection(); context.Database.EnsureCreated(); InitializeConstants.Initialize(context); }
public AnnotationsController( GeneAnnotationDBContext context, IMapper mapper ) { _context = context; _mapper = mapper; }
public GenesController(GeneAnnotationDBContext context, IMapper mapper, IGeneRepository geneRepository, IGeneCoordinateRepository geneCoordinateRepository ) { _context = context; _mapper = mapper; _geneRepository = geneRepository; }
public GeneVariantsController( GeneAnnotationDBContext context, IGeneVariantRepository geneVariantRepository, IMapper mapper ) { _context = context; _mapper = mapper; _geneVariantRepository = geneVariantRepository; }
public LikeVariantLiteratureDataLoader( GeneAnnotationDBContext context, IReadOnlyList <string> currentRow, GeneVariant currentVariant ) { _context = context; _currentRow = currentRow; CurrentVariant = currentVariant; }
public BaseEfRepository(GeneAnnotationDBContext context) { _context = context; var typeName = typeof(T).Name; var propertyInfo = _context .GetType() .GetProperty(typeName); _dbSet = (DbSet <T>)propertyInfo.GetValue(_context, null); }
public static void ClearTables(GeneAnnotationDBContext context) { foreach (var tableName in GetDbTableList(context)) { var sqlString = "DELETE FROM " + tableName + "; " ; context.Database.ExecuteSqlCommand(sqlString); } }
public static void FillDb(GeneAnnotationDBContext context) { var properties = context.GetType().GetProperties(); foreach (var propertyInfo in properties) { var property = propertyInfo.GetValue(context); var testDataClassName = propertyInfo.Name + "TestData"; var type = Type.GetType(testDataClassName); var myObject = Activator.CreateInstance(type); } }
private static VariantType[] VariantTypeTable(GeneAnnotationDBContext context) { var variantTypes = new[] { new VariantType { Name = "Deletion (whole gene)" }, new VariantType { Name = "Partial Deletion (intragenic)" }, new VariantType { Name = "Partial Deletion (deleted 5')" }, new VariantType { Name = "Partial Deletion (deleted 3')" }, new VariantType { Name = "Duplication (whole gene)" }, new VariantType { Name = "Partial Duplication (intragenic)" }, new VariantType { Name = "Partial Duplication (duplicated 5')" }, new VariantType { Name = "Partial Duplication (duplicated 3')" }, new VariantType { Name = "SNV, predicted lof" }, new VariantType { Name = "SNV, predicted gof" }, new VariantType { Name = "Splice site" }, new VariantType { Name = "GWAS (within gene or nearest to this gene)" }, }; foreach (var variantType in variantTypes) { context.VariantType.Add(variantType); } context.SaveChanges(); return(variantTypes); }
private static void BasicInit <T>( GeneAnnotationDBContext context, IEnumerable <T> objects ) where T : class { var passedType = typeof(T); var typeString = passedType.Name; foreach (var originType in objects) { var property = (DbSet <T>)context.GetType().GetProperty(typeString).GetValue(context); property.Add(originType); // (context.GetType().GetProperty(typeof(T).Name) as DbSet<T>).Add(originType); } context.SaveChanges(); }
public BaseControllerTest(bool initDb = true) { if (initDb) { Environment.SetEnvironmentVariable(InitializeConstants.GA_DB_RESET_VARIABLE_NAME, "1"); } // just to make sure mapper is initialzed TestServer = new TestServer( new WebHostBuilder() .UseEnvironment("Development") .UseStartup <TestStartup>() ); Client = TestServer.CreateClient(); Client.BaseAddress = new Uri("http://localhost"); Context = TestServer.Host.Services.GetService(typeof(GeneAnnotationDBContext)) as GeneAnnotationDBContext; TestStartup.InitializeDatabase(Context); }
public InitializeDbTest() { var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = ":memory:" }; var connectionString = connectionStringBuilder.ToString(); var connection = new SqliteConnection(connectionString); var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlite() .AddDbContext <GeneAnnotationDBContext>( options => options.UseSqlite(connection) ) .BuildServiceProvider(); _context = (GeneAnnotationDBContext)serviceProvider.GetService(typeof(GeneAnnotationDBContext)); _context.Database.OpenConnection(); _context.Database.EnsureCreated(); }
private static Literature[] GetLiteratures(GeneAnnotationDBContext context) { var literatures = new[] { new Literature { Url = "http://lit1", Title = "lit1" }, new Literature { Url = "http://lit2", Title = "lit2" }, }; foreach (var lit in literatures) { context.Literature.Add(lit); } context.SaveChanges(); return(literatures); }
private static GeneLocation[] GeneLocationTable(GeneAnnotationDBContext context, Gene[] genes) { var geneLocations = new[] { new GeneLocation { Gene = genes[0], Locus = "locus", HgVersion = 19 }, new GeneLocation { Gene = genes[0], Locus = "locus", HgVersion = 38 } }; foreach (var geneLocation in geneLocations) { context.GeneLocation.Add(geneLocation); } context.SaveChanges(); return(geneLocations); }
private static IEnumerable <Symbol> GetSymbols(GeneAnnotationDBContext context, Gene[] genes) { var symbols = new[] { new Symbol { Name = "ABCF3", Gene = genes[0], ActiveDate = DateTime.Now }, new Symbol { Name = "ABCG1", Gene = genes[0], ActiveDate = DateTime.Now.AddDays(-1) }, }; foreach (var symbol in symbols) { context.Symbol.Add(symbol); } context.SaveChanges(); return(symbols); }
private static GeneName[] GeneNames(GeneAnnotationDBContext context, Gene[] genes) { var geneNames = new[] { new GeneName { Gene = genes[0], ActiveDate = DateTime.Now, Name = "Name 1" }, new GeneName { Gene = genes[0], ActiveDate = DateTime.Now.AddDays(-1), Name = "Name 2" }, }; foreach (var geneName in geneNames) { context.GeneName.Add(geneName); } context.SaveChanges(); return(geneNames); }
public static IList <string> GetDbTableList(GeneAnnotationDBContext context) { var contextProperties = context.GetType().GetProperties(); return(new[] { "accession", "annotation", "annotation_author", "author_literature", "author", "annotation_literature", "annotation_gene_variant_literature", "gene_variant_literature", "literature", "annotation_gene", "annotation_gene_variant", "annotation", "symbol", "gene_location", "gene_origin_type", "origin_type", "app_user", "gene_variant", "gene_name", "gene_location", "gene", "human_genome_assembly", "zygosity_type", "variant_type", "call_type_gene_variant", "call_type", "disorder", "gene_var_lit_disorder", "chromosome", "name_synonym", "synonym", "pathogenic_support_category", }); }
private static OriginType[] GetOriginTypes(GeneAnnotationDBContext context) { var originTypes = new[] { new OriginType() { Name = "origin 1" }, new OriginType() { Name = "origin 2" }, }; foreach (var origin in originTypes) { context.OriginType.Add(origin); } context.SaveChanges(); return(originTypes); }
public VariantInsertTest() { ILoggerFactory loggerFactory = new LoggerFactory(); loggerFactory.AddConsole(); loggerFactory.AddDebug(); var contextOptionsBuilder = new DbContextOptionsBuilder <GeneAnnotationDBContext>(); contextOptionsBuilder.UseLoggerFactory(loggerFactory); var connectionString = @"Server=localhost;Database=GeneAnnotationDB;User=sa;Password=C0rv3tt3!"; contextOptionsBuilder.UseSqlServer(connectionString); _context = new GeneAnnotationDBContext(contextOptionsBuilder.Options); _context.Database.OpenConnection(); _context.Database.EnsureCreated(); SetupTypeMap(); }
private static Chromosome[] ChromosomeTable(GeneAnnotationDBContext context) { var chromosomeNames = new[] { "1", "2", "3", "X", "Y" }; var chromosomes = new List <Chromosome>(); foreach (var chromosomeName in chromosomeNames) { var chromosome = new Chromosome { Name = chromosomeName }; chromosomes.Add(chromosome); context.Chromosome.Add(chromosome); } context.SaveChanges(); return(chromosomes.ToArray()); }