private bool FindValue(Annotation a, ColumnName key, out string value) { if (nameKeyMap.ContainsKey(key)) { HashSet<string> keys = nameKeyMap[key]; foreach (var ck in keys) { if (a.Annotations.ContainsKey(ck)) { value = (a.Annotations[ck] as string).Trim(); return true; } } } value = StatusValue.NA; return false; }
public override IEnumerable<string> Process() { var format = new AnnotationFormat(); var items = format.ReadFromFile(_options.ClinicalFile); format.Format.Headers = sampleBarcodeKey + "\t" + format.Format.Headers; var itemMap = items.ToDictionary(m => m.BarCode()); using (StreamReader sr = new StreamReader(_options.DataFile)) { var barcodes = sr.ReadLine().Split('\t').Where(m => m.StartsWith("TCGA")).ToList(); List<Annotation> found = new List<Annotation>(); foreach (var barcode in barcodes) { var patient = barcode.Substring(0, 12); Annotation ann; if (!itemMap.TryGetValue(patient, out ann)) { if (_options.ThrowException) { throw new Exception("Cannot find patient information for " + patient); } Console.Error.WriteLine("Cannot find patient information for " + patient); ann = new Annotation(); } var curann = new Annotation(); curann.Annotations[sampleBarcodeKey] = barcode; curann.Annotations[TCGAClinicalInformation.BcrPatientBarcode] = patient; foreach (var e in ann.Annotations) { curann.Annotations[e.Key] = e.Value; } found.Add(curann); } format.WriteToFile(_options.OutputFile, found); } return new[] { _options.OutputFile }; }
private string FindValue(Annotation a, Dictionary<string, HashSet<string>> namekeys, string p) { var keys = namekeys[p]; foreach (var ann in a.Annotations) { if (keys.Contains(ann.Key)) { return (ann.Value as string).Trim(); } } return "NA"; }
private string FindValue(Annotation a, ColumnName key) { string result; FindValue(a, key, out result); return result; }