public async Task Index() { var list = await GffFileReader.FromFile(GffPath); foreach (var gff in list) { var attributes = gff.Attributes; var id = attributes.GetValueOrDefault("protein_id"); if (id == null) { continue; } var note = attributes.GetValueOrDefault("Note"); var product = attributes.GetValueOrDefault("product"); var data = new GeneData(id, gff.Sequence) { Symbol = attributes.GetValueOrDefault("gene"), Product = product != null?Uri.UnescapeDataString(product) : null, LocusTag = attributes.GetValueOrDefault("locus_tag") ?? throw new Exception("Locus tag missing"), Position = gff.Start, Length = gff.End - gff.Start + 1, Strand = gff.Strand, Score = gff.Score, Phase = gff.Phase, Note = note != null?Uri.UnescapeDataString(note) : null }; await Database.Index(data); } } }
public async Task IndexSnp(SnpSource source, Snp snp) { if (Genes == null) { Genes = await Database.GetAllGene(); } var doi = source.Study?.Doi; SnpData snpData = SnpData.FromSnp(snp); if (doi != null) { var citation = await DoiClient.GetCitation(doi); if (citation != null) { snpData.Annotations.Add(new SnpData.Annotation { Study = citation, Lineage = snp.Attributes.GetValueOrDefault("lineage") }); } } ; snpData = snpData with { Gene = Genes .FirstOrDefault(v => v.Position <snp.Position && v.Position + v.Length> snp.Position) }; await Database.Index(snpData); }
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); } } }