public ValidateLimits() { // dbLimits = new MongoModel("Limits"); string relativepath = "/App_Data/system.conf"; string absolutedpath = HttpContext.Current.Server.MapPath(relativepath); Filelimits = new DataFileManager(absolutedpath, "juanin"); }
/** * Create a data file for the tests */ void CreateFile() { if (!File.Exists(path)) { File.Create(path).Dispose(); } DataFileManager.ResetFile(path); }
public async Task ThenThePageContentIncludesTheEpaoName() { var response = _context.Get <HttpResponseMessage>(ContextKeys.HttpResponse); var actualContent = await response.Content.ReadAsStringAsync(); var json = DataFileManager.GetFile("course-epao.json"); var expectedApiResponse = JsonConvert.DeserializeObject <CourseEpao>(json); actualContent.Should().Contain(HttpUtility.HtmlEncode(expectedApiResponse.Epao.Name)); }
public OmimVcfCreator(string inputPrefix, string refSeqPath, string outPath) { _inputPrefix = inputPrefix; _outPath = outPath; _compressedSequence = new CompressedSequence(); var reader = new CompressedSequenceReader(FileUtilities.GetReadStream(refSeqPath), _compressedSequence); _renamer = _compressedSequence.Renamer; _dataFileManager = new DataFileManager(reader, _compressedSequence); _processedGeneSet = new HashSet <string>(); }
public async Task ThenThereIsARowForEachCourse() { var response = _context.Get <HttpResponseMessage>(ContextKeys.HttpResponse); var actualContent = await response.Content.ReadAsStringAsync(); var json = DataFileManager.GetFile("course-list.json"); var expectedApiResponse = JsonConvert.DeserializeObject <CourseList>(json); foreach (var course in expectedApiResponse.Courses) { actualContent.Should().Contain(HttpUtility.HtmlEncode(course.Title)); } }
/// <summary> /// constructor /// </summary> public PianoAnnotationSource(Stream transcriptCacheStream, CompressedSequenceReader compressedSequenceReader) { OverlappingTranscripts = new List <Transcript>(); _performanceMetrics = PerformanceMetrics.Instance; _compressedSequence = new CompressedSequence(); _dataFileManager = new DataFileManager(compressedSequenceReader, _compressedSequence); _dataFileManager.Changed += LoadData; _renamer = _compressedSequence.Renamer; _aminoAcids = new AminoAcids(); _vid = new VID(); LoadTranscriptCache(transcriptCacheStream, _renamer.NumRefSeqs, out _transcriptIntervalForest); }
public IList <DataLine> GetDataLines(string filePath) { var dataLineDtos = DataFileManager.GetLines(filePath); var dataLines = new List <DataLine>(); foreach (var dataLineDto in dataLineDtos) { DataLine dataLine; dataLine = Mapper.Map <DataLine>(dataLineDto); dataLines.Add(dataLine); } return(dataLines); }
/** * Select the next platform depending of the part of the body */ protected void AdaptProbabilities() { string playerName = PlayerPrefs.GetString("PlayerName"); Dictionary <string, float> data = DataFileManager.FindData(playerName); if (data == null) { return; } float adjustment = 0.90f; foreach (KeyValuePair <string, float> entry in data) { if (entry.Value >= 0.5) { int index1 = -1; for (int i = 0; i < platformsList.Length; i++) { if (platformsList[i].name == entry.Key) { index1 = i; break; } } if (index1 != -1) { int index2 = -1; for (int i = 0; i < platformsList.Length; i++) { if (platformsList[i].GetComponent <PrefabController>().myType == platformsList[index1].GetComponent <PrefabController>().myType&& platformsList[i].tag == "coinPlatform") { index2 = i; break; } } if (index2 != -1) { int diffWeight = System.Convert.ToInt32(platformsList[index1].GetComponent <PrefabController>().InitialSpawnWeight *(entry.Value * adjustment)); platformsList[index1].GetComponent <PrefabController>().Weight = platformsList[index1].GetComponent <PrefabController>().Weight - diffWeight; platformsList[index2].GetComponent <PrefabController>().Weight = platformsList[index2].GetComponent <PrefabController>().Weight + diffWeight; } } } } }
public async Task ThenTheSectorsAndLevelsAreAvailableToFilter() { var response = _context.Get <HttpResponseMessage>(ContextKeys.HttpResponse); var actualContent = await response.Content.ReadAsStringAsync(); var json = DataFileManager.GetFile("courses.json"); var expectedApiResponse = JsonConvert.DeserializeObject <TrainingCourses>(json); foreach (var sector in expectedApiResponse.Sectors) { actualContent.Should().Contain(HttpUtility.HtmlEncode(sector.Route)); } foreach (var level in expectedApiResponse.Levels) { actualContent.Should().Contain($"Level {level.Code} - {HttpUtility.HtmlEncode(level.Name)}"); } }
public MustGenotypeExtractor(string compressedSeqPath, string oneKGenomeVcf, string clinvarVcf, string cosmicVcf, bool isHg19 = false) { _compressedSequence = new CompressedSequence(); _dataFileManager = new DataFileManager(new CompressedSequenceReader(FileUtilities.GetReadStream(compressedSeqPath), _compressedSequence), _compressedSequence); _assembly = _compressedSequence.GenomeAssembly == GenomeAssembly.GRCh37 && isHg19? GenomeAssembly.hg19:_compressedSequence.GenomeAssembly; if (_assembly == GenomeAssembly.Unknown) { throw new Exception("Genome assembly must be either GRCh37 or GRCh38"); } if (_compressedSequence.GenomeAssembly == GenomeAssembly.GRCh38 && isHg19) { throw new Exception("reference sequence is GRCh38 while generating hg19 files"); } _oneKGenomeReader = string.IsNullOrEmpty(oneKGenomeVcf)? null: GZipUtilities.GetAppropriateStreamReader(oneKGenomeVcf); _clinvarReader = string.IsNullOrEmpty(clinvarVcf) ? null : GZipUtilities.GetAppropriateStreamReader(clinvarVcf); _cosmicReader = string.IsNullOrEmpty(cosmicVcf) ? null : GZipUtilities.GetAppropriateStreamReader(cosmicVcf); }
private void DeleteButton_Click(object sender, EventArgs e) { var currentItem = ServerList.Text; if (string.IsNullOrEmpty(currentItem)) { MessageBox.Show("There is no server to delete."); return; } var item = DataFileManager.Data.AllServers.FirstOrDefault(x => x.Name == currentItem); if (item == null) { RefreshServerList(); return; } DataFileManager.Data.AllServers.Remove(item); DataFileManager.SaveData(); RefreshServerList(); }
/** * Unit test of the AddNewPlayer function */ void TestAddNewPlayer() { print("TestAddNewPlayer..."); int id; PlayerData newPlayer; CreateFile(); //Player not in the file id = DataFileManager.NextId("Test", path); Assert.AreEqual(1, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!")); //Add a player newPlayer = new PlayerData("Test", 1, 2, 3, 4, 0, 0, 1, 0, 0); DataFileManager.AddNewPlayer(newPlayer, path); id = DataFileManager.NextId("Test", path); Assert.AreEqual(2, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!")); id = DataFileManager.NextId("Test2", path); Assert.AreEqual(1, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 1!")); //Add an other game for the player newPlayer = new PlayerData("Test", 1, 2, 3, 4, 0, 0, 0, 1, 0); DataFileManager.AddNewPlayer(newPlayer, path); id = DataFileManager.NextId("Test", path); Assert.AreEqual(3, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 3!")); //Add an other player newPlayer = new PlayerData("Test2", 1, 2, 3, 4, 0, 0, 0, 1, 0); DataFileManager.AddNewPlayer(newPlayer, path); id = DataFileManager.NextId("Test", path); Assert.AreEqual(3, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 3!")); id = DataFileManager.NextId("Test2", path); Assert.AreEqual(2, id, string.Format("<color=#{0:X2}{1:X2}{2:X2}>{3}</color>", (byte)(255), (byte)(0), (byte)(0), "...FAILED : Value should be 2!")); DeleteFile(); }
/// <summary> /// Check if username and password is valid, if it is, sets sessions and formauth to true /// </summary> /// <param name="username">The user name</param> /// <param name="password">The User password</param> /// <returns>Index View if valid user, Login view if invalid user</returns> /// <author>Galaviz Alejos Luis Angel</author> public ActionResult Login(string username, string password) { if (username == "" || password == "") { this.Redirect("/Login"); } //Check the user on the database //usertable = new UserTable(); BsonDocument doc = usertable.Login(username, password); ProfileTable profiletable = new ProfileTable(); //If the return is null, is an invalid user if (doc != null) { //User Password time validation if (doc["_id"].AsObjectId.ToString() != "52e95ab907719e0d40637d96") { JObject userInformation = JsonConvert.DeserializeObject <JObject>(usertable.GetRow(doc["_id"].AsObjectId.ToString())); if (userInformation["lastChgPassword"] != null) { try { DateTime d1 = DateTime.ParseExact(userInformation["lastChgPassword"].ToString(), "dd/MM/yyyy HH:mm:ss", null); DateTime d2 = DateTime.Now; systemSettingsTable = new SystemSettingsTable(); JArray cantDays = JsonConvert.DeserializeObject <JArray>(systemSettingsTable.Get("name", "daysChangePassword")); string days = (from mov in cantDays select(string) mov["days"]).First().ToString(); TimeSpan time = d2 - d1; int NrOfDays = time.Days; if (int.Parse(days) <= NrOfDays) { ViewBag.Message = "Timeout"; ViewData["timeout"] = "Timeout"; List <string> backgrounds = Design.getBackgrounds(); return(View("Index", backgrounds)); } } catch (Exception ex) { ViewBag.Error = true; ViewBag.Message = ex.ToString(); ViewData["timeout"] = ex.ToString(); List <string> backgrounds = Design.getBackgrounds(); return(View("Index", backgrounds)); } } else { try { JObject user = JsonConvert.DeserializeObject <JObject>(usertable.GetRow(doc["_id"].AsObjectId.ToString())); user["lastChgPassword"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); usertable.saveRow(JsonConvert.SerializeObject(user), user["_id"].ToString()); } catch (Exception ex) { // throw new Exception(ex.ToString()); //return Redirect("~/Home"); } //END - User Password time validation } } DataFileManager Filelimits; string filepath = "/App_Data/system.conf"; string absolutedpath = Server.MapPath(filepath); Filelimits = new DataFileManager(absolutedpath, "juanin"); if (!Filelimits.empty()) { //Set user name (to show on the upper right corner of the system) this.Session["LoggedUser"] = ""; try { this.Session["Semaphores"] = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); HttpCookie aCookiesem = new HttpCookie("semaphores"); aCookiesem.Value = Session["Semaphores"].ToString(); aCookiesem.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookiesem); } catch (Exception ex) { } this.Session["Username"] = ""; try { this.Session["Username"] = doc["name"].AsString; this.Session["LoggedUser"] += doc["name"].AsString; try { this.Session["LoggedUser"] += " " + doc["lastname"].AsString; } catch (Exception e) { /*Ignored*/ } } catch (Exception e) { /*Ignored*/ } //If needed for user transactions this.Session["_id"] = doc["_id"].AsObjectId; HttpCookie aCookie2 = new HttpCookie("_id2"); aCookie2.Value = doc["_id"].AsObjectId.ToString(); aCookie2.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookie2); //Check if there exist the image extension registry on database, if it exist, sets the relative //path try { if (!string.IsNullOrEmpty(doc["imgext"].ToString())) { //Relative path to save images string relativepath = string.Format("\\Uploads\\Images\\{0}.{1}", Session["_id"].ToString(), doc["imgext"].ToString()); //Check if profile picture file exists on the server if (System.IO.File.Exists(Server.MapPath(relativepath))) { //if it exist, sets the profile picture url this.Session["ProfilePicture"] = Url.Content(relativepath); HttpCookie aCookie4 = new HttpCookie("_picture"); aCookie4.Value = Url.Content(relativepath); aCookie4.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookie4); } else { //Set picture to default this.Session["ProfilePicture"] = null; } } } catch (Exception e) { /*Ignored*/ } string usuarioid = Session["_id"].ToString(); String profileid = usertable.getRowString(usuarioid); JObject rowArray = JsonConvert.DeserializeObject <JObject>(profileid); var jdatos = ""; if (rowArray["permissionsHTK"] != null) { string arraypermisos = rowArray["permissionsHTK"].ToString(); JObject allp = JsonConvert.DeserializeObject <JObject>(arraypermisos); jdatos = JsonConvert.SerializeObject(allp); this.Session["Permissions"] = jdatos.ToString(); } else { string idpro = rowArray["profileId"].ToString(); String profiles = profiletable.GetRow(idpro); JObject rowArraypro = JsonConvert.DeserializeObject <JObject>(profiles); string arraypermisos = rowArraypro["permissionsHTK"].ToString(); JObject allp = JsonConvert.DeserializeObject <JObject>(arraypermisos); jdatos = JsonConvert.SerializeObject(allp); this.Session["Permissions"] = jdatos.ToString(); } try { this.Session["PermissionsClient"] = Filelimits["scenario"]["modules"].ToString(); string filedata = Filelimits["scenario"]["modules"].ToString(); HttpCookie aCookiep = new HttpCookie("permissionsclient"); aCookiep.Value = Filelimits["scenario"]["modules"].ToString(); aCookiep.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookiep); } catch (Exception ex) { this.Session["PermissionsClient"] = ""; } HttpCookie aCookie = new HttpCookie("permissions"); aCookie.Value = jdatos.ToString(); aCookie.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookie); HttpCookie aCookie1 = new HttpCookie("_loggeduser"); aCookie1.Value = Session["LoggedUser"].ToString(); aCookie1.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookie1); HttpCookie aCookie3 = new HttpCookie("_username"); aCookie3.Value = Session["Username"].ToString(); aCookie3.Expires = DateTime.Now.AddDays(10); Response.Cookies.Add(aCookie3); //Sets the login authorization FormsAuthentication.SetAuthCookie("User", false); TimeSpan time = FormsAuthentication.Timeout; // FormsAuthentication.Timeout.Subtract(time); //Redirect Index FormsAuthentication.Timeout.Subtract(time); /* TimeSpan time2= TimeSpan.Parse("00:04:00"); * FormsAuthentication.Timeout.Add(time2); * string horasuma2 = DateTime.Now.ToString("HH:mm:ss"); * TimeSpan timenow = TimeSpan.Parse(horasuma2); * int total = time2.Minutes - timenow.Minutes;*/ return(Redirect("~/Home")); } else { ViewBag.Error = true; ViewBag.Message = "Error de Permisos"; List <string> backgrounds = Design.getBackgrounds(); return(View("Index", backgrounds)); } } else { //Set error and return to login page ViewBag.Error = true; ViewBag.Message = "Error de Login"; List <string> backgrounds = Design.getBackgrounds(); return(View("Index", backgrounds)); } }
// constructor public CreateSupplementaryDatabase( string compressedReferencePath, string nsdBaseFileName, string dbSnpFileName = null, string cosmicVcfFile = null, string cosmicTsvFile = null, string clinVarFileName = null, string oneKGenomeAfFileName = null, string evsFileName = null, string exacFileName = null, List <string> customFiles = null, string dgvFileName = null, string oneKSvFileName = null, string clinGenFileName = null, string chrWhiteList = null) { _nsdBaseFileName = nsdBaseFileName; _dataSources = new List <DataSourceVersion>(); _iSupplementaryDataItemList = new List <IEnumerator <SupplementaryDataItem> >(); _supplementaryIntervalList = new List <SupplementaryInterval>(); Console.WriteLine("Creating supplementary annotation files... Data version: {0}, schema version: {1}", SupplementaryAnnotationCommon.DataVersion, SupplementaryAnnotationCommon.SchemaVersion); _compressedSequence = new CompressedSequence(); var compressedSequenceReader = new CompressedSequenceReader(FileUtilities.GetReadStream(compressedReferencePath), _compressedSequence); _renamer = _compressedSequence.Renamer; _dataFileManager = new DataFileManager(compressedSequenceReader, _compressedSequence); if (!string.IsNullOrEmpty(chrWhiteList)) { Console.WriteLine("Creating SA for the following chromosomes only:"); foreach (var refSeq in chrWhiteList.Split(',')) { InputFileParserUtilities.ChromosomeWhiteList.Add(_renamer.GetEnsemblReferenceName(refSeq)); Console.Write(refSeq + ","); } Console.WriteLine(); } else { InputFileParserUtilities.ChromosomeWhiteList = null; } if (dbSnpFileName != null) { AddSourceVersion(dbSnpFileName); var dbSnpReader = new DbSnpReader(new FileInfo(dbSnpFileName), _renamer); var dbSnpEnumerator = dbSnpReader.GetEnumerator(); _iSupplementaryDataItemList.Add(dbSnpEnumerator); } if (cosmicVcfFile != null && cosmicTsvFile != null) { AddSourceVersion(cosmicVcfFile); var cosmicReader = new MergedCosmicReader(cosmicVcfFile, cosmicTsvFile, _renamer); var cosmicEnumerator = cosmicReader.GetEnumerator(); _iSupplementaryDataItemList.Add(cosmicEnumerator); } if (oneKGenomeAfFileName != null) { AddSourceVersion(oneKGenomeAfFileName); var oneKGenReader = new OneKGenReader(new FileInfo(oneKGenomeAfFileName), _renamer); var oneKGenEnumerator = oneKGenReader.GetEnumerator(); _iSupplementaryDataItemList.Add(oneKGenEnumerator); } if (oneKSvFileName != null) { if (oneKGenomeAfFileName == null) { AddSourceVersion(oneKSvFileName); } var oneKGenSvReader = new OneKGenSvReader(new FileInfo(oneKSvFileName), _renamer); var oneKGenSvEnumerator = oneKGenSvReader.GetEnumerator(); _iSupplementaryDataItemList.Add(oneKGenSvEnumerator); } if (evsFileName != null) { AddSourceVersion(evsFileName); var evsReader = new EvsReader(new FileInfo(evsFileName), _renamer); var evsEnumerator = evsReader.GetEnumerator(); _iSupplementaryDataItemList.Add(evsEnumerator); } if (exacFileName != null) { AddSourceVersion(exacFileName); var exacReader = new ExacReader(new FileInfo(exacFileName), _renamer); var exacEnumerator = exacReader.GetEnumerator(); _iSupplementaryDataItemList.Add(exacEnumerator); } if (clinVarFileName != null) { AddSourceVersion(clinVarFileName); var clinVarReader = new ClinVarXmlReader(new FileInfo(clinVarFileName), compressedSequenceReader, _compressedSequence); var clinVarList = clinVarReader.ToList(); clinVarList.Sort(); Console.WriteLine($"{clinVarList.Count} clinvar items read form XML file"); IEnumerator <ClinVarItem> clinVarEnumerator = clinVarList.GetEnumerator(); _iSupplementaryDataItemList.Add(clinVarEnumerator); } if (dgvFileName != null) { AddSourceVersion(dgvFileName); var dgvReader = new DgvReader(new FileInfo(dgvFileName), _renamer); var dgvEnumerator = dgvReader.GetEnumerator(); _iSupplementaryDataItemList.Add(dgvEnumerator); } if (clinGenFileName != null) { AddSourceVersion(clinGenFileName); var clinGenReader = new ClinGenReader(new FileInfo(clinGenFileName), _renamer); var clinGenEnumerator = clinGenReader.GetEnumerator(); _iSupplementaryDataItemList.Add(clinGenEnumerator); } if (customFiles != null) { foreach (var customFile in customFiles) { AddSourceVersion(customFile); var customReader = new CustomAnnotationReader(new FileInfo(customFile), _renamer); var customEnumerator = customReader.GetEnumerator(); _iSupplementaryDataItemList.Add(customEnumerator); } } // initializing the IEnumerators in the list foreach (var iDataEnumerator in _iSupplementaryDataItemList) { if (!iDataEnumerator.MoveNext()) { _iSupplementaryDataItemList.Remove(iDataEnumerator); } } _additionalItemsList = new List <SupplementaryDataItem>(); }