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); } } }