public async Task Index() { var reader = await FastaReader.CreateAsync(FastaPath); foreach (var identifier in reader.Identifiers) { var comment = reader.CommentOf(identifier); var attributes = AttributesParser.Parse(comment); var id = attributes.GetValueOrDefault("protein_id"); if (id == null) { throw new Exception("Id missing"); } var range = ParseRange(attributes.GetValueOrDefault("location", "")); var data = new GeneData(id, SequenceId) { Symbol = attributes.GetValueOrDefault("gene"), Product = attributes.GetValueOrDefault("protein"), LocusTag = attributes.GetValueOrDefault("locus_tag") ?? throw new Exception("Locus tag missing"), // We can infer this from the fasta reader if we prevent '\n' from being in the sequence Position = range?.Item1, Length = range != null ? range?.Item2 - range?.Item1 + 1 : null }; await Database.Index(data); } } }
public void TestAttributeParser() { // arrange const string mapboxfile = "mapbox.vector.tile.tests.testdata.14-8801-5371.vector.pbf"; var pbfStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(mapboxfile); var tile = Serializer.Deserialize <Tile>(pbfStream); var keys = tile.Layers[0].Keys; var values = tile.Layers[0].Values; var tagsf1 = tile.Layers[0].Features[0].Tags; // act var attributes = AttributesParser.Parse(keys, values, tagsf1); // assert Assert.IsTrue(attributes.Count == 2); Assert.IsTrue(attributes[0].Key == "class"); Assert.IsTrue((string)attributes[0].Value == "park"); Assert.IsTrue(attributes[1].Key == "osm_id"); Assert.IsTrue(attributes[1].Value.ToString() == "3000000224480"); }
public PsaMovesetHandler(PsaFile psaFile) { PsaFile = psaFile; AttributesHandler = new AttributesParser(PsaFile); DataTableHandler = new DataTableHandler(PsaFile); ExternalDataHandler = new ExternalDataHandler(PsaFile); int dataSectionLocation = DataTableHandler.GetDataTableEntryByName("data").Location; string movesetBaseName = GetMovesetBaseName(); int numberOfSpecialActions = (PsaFile.DataSection[dataSectionLocation + 10] - PsaFile.DataSection[dataSectionLocation + 9]) / 4; int codeBlockDataStartLocation = 2014 + numberOfSpecialActions * 2; PsaCommandHandler psaCommandHandler = new PsaCommandHandler(psaFile, dataSectionLocation, codeBlockDataStartLocation); CodeBlocksHandler codeBlocksHandler = new CodeBlocksHandler(psaFile, dataSectionLocation, psaCommandHandler); ActionsHandler = new ActionsHandler(PsaFile, dataSectionLocation, codeBlocksHandler, psaCommandHandler); SubActionsHandler = new SubActionsHandler(PsaFile, dataSectionLocation, codeBlocksHandler, psaCommandHandler); SubRoutinesHandler = new SubRoutinesHandler(PsaFile, dataSectionLocation, ActionsHandler, SubActionsHandler, psaCommandHandler); ActionOverridesHandler = new ActionOverridesHandler(PsaFile, dataSectionLocation, ActionsHandler, psaCommandHandler); ArticlesHandler = new ArticlesHandler(PsaFile, dataSectionLocation, movesetBaseName, psaCommandHandler); CharacterParamsHandler = new CharacterParamsHandler(PsaFile, dataSectionLocation, movesetBaseName, psaCommandHandler); MiscHandler = new MiscHandler(PsaFile, dataSectionLocation, movesetBaseName, numberOfSpecialActions); }