/// <summary> /// Extracts a exac item(s) from the specified VCF line. /// </summary> /// <param name="vcfline"></param> /// <returns></returns> public List <ExacItem> ExtractItems(string vcfline) { if (vcfline == null) { return(null); } var splitLine = vcfline.Split('\t'); // we don't care about the many fields after info field if (splitLine.Length < 8) { return(null); } Clear(); var chromosome = splitLine[VcfCommon.ChromIndex]; if (!_refChromDict.ContainsKey(chromosome)) { return(null); } var chrom = _refChromDict[chromosome]; var position = int.Parse(splitLine[VcfCommon.PosIndex]); //we have to get it from RSPOS in info var refAllele = splitLine[VcfCommon.RefIndex]; var altAlleles = splitLine[VcfCommon.AltIndex].Split(','); var infoFields = splitLine[VcfCommon.InfoIndex]; // parses the info fields and extract frequencies, coverage, num samples. ParseInfoField(infoFields); if (_anAdj == 0) { return(null); } var exacItemsList = new List <ExacItem>(); for (int i = 0; i < altAlleles.Length; i++) { exacItemsList.Add(new ExacItem( chrom, position, refAllele, altAlleles[i], ComputingUtilities.GetCoverage(_totalDepth, _anAdj / 2.0), //(int) Math.Round(_totalDepth*1.0/ (_anAdj/2.0), MidpointRounding.AwayFromZero),//to be consistant with evs, we use integer values for coverage _anAdj, _anAfr, _anAmr, _anEas, _anFin, _anNfe, _anOth, _anSas, GetAlleleCount(_acAdj, i), GetAlleleCount(_acAfr, i), GetAlleleCount(_acAmr, i), GetAlleleCount(_acEas, i), GetAlleleCount(_acFin, i), GetAlleleCount(_acNfe, i), GetAlleleCount(_acOth, i), GetAlleleCount(_acSas, i)) ); } return(exacItemsList); }
public string GetJsonString() { var sb = new StringBuilder(); var jsonObject = new JsonObject(sb); jsonObject.AddStringValue("allAf", ComputingUtilities.ComputeFrequency(_alleleNum, _alleleCount), false); jsonObject.AddIntValue("allAn", _alleleNum); jsonObject.AddIntValue("allAc", _alleleCount); jsonObject.AddIntValue("allHc", _homCount); if (_failedFilter) { jsonObject.AddBoolValue("failedFilter", true); } return(sb.ToString()); }