public bool CoElutedByScanNum(LcMsFeature other, int tolScan = 0) { if (tolScan == 0) { tolScan++; } if (MinScanNum - tolScan < other.MinScanNum && other.MinScanNum < MaxScanNum + tolScan) { return(true); } if (MinScanNum - tolScan < other.MaxScanNum && other.MaxScanNum < MaxScanNum + tolScan) { return(true); } if (other.MinScanNum - tolScan < MinScanNum && MinScanNum < other.MaxScanNum + tolScan) { return(true); } if (other.MinScanNum - tolScan < MaxScanNum && MaxScanNum < other.MaxScanNum + tolScan) { return(true); } return(false); }
/* * public static List<LcMsFeature> LoadProMexResult(string featureFilePath) * { * return LoadProMexResult(0, featureFilePath); * } */ public static List <LcMsFeature> LoadProMexResult(int dataId, string featureFilePath, LcMsRun run, double minMass = 2000, double maxMass = 50000) { var featureList = new List <LcMsFeature>(); var tsvReader = new TsvFileParser(featureFilePath); //var run = (rawFilePath == null || !File.Exists(rawFilePath)) ? null : PbfLcMsRun.GetLcMsRun(rawFilePath); var featureIds = tsvReader.GetData("FeatureID"); var minScans = tsvReader.GetData("MinScan"); var maxScans = tsvReader.GetData("MaxScan"); var abu = tsvReader.GetData("Abundance"); var minCharges = tsvReader.GetData("MinCharge"); var maxCharges = tsvReader.GetData("MaxCharge"); var monoMass = tsvReader.GetData("MonoMass"); var minElutionTime = tsvReader.GetData("MinElutionTime"); var maxElutionTime = tsvReader.GetData("MaxElutionTime"); var repCharges = tsvReader.GetData("RepCharge"); var repScans = tsvReader.GetData("RepScan"); var repMzs = tsvReader.GetData("RepMz"); var scores = tsvReader.GetData("LikelihoodRatio"); for (var i = 0; i < tsvReader.NumData; i++) { var abundance = double.Parse(abu[i]); var repMass = double.Parse(monoMass[i]); if (repMass < minMass || repMass > maxMass) { continue; } var minCharge = int.Parse(minCharges[i]); var maxCharge = int.Parse(maxCharges[i]); var minScan = int.Parse(minScans[i]); var maxScan = int.Parse(maxScans[i]); var fid = int.Parse(featureIds[i]); var repCharge = (repCharges != null) ? int.Parse(repCharges[i]) : (int)Math.Round(0.5 * (minCharge + maxCharge)); var repMz = (repMzs != null) ? double.Parse(repMzs[i]) : (repMass / repCharge) + Constants.Proton; var repScanNum = (repScans != null) ? int.Parse(repScans[i]) : minScan; var score = (scores != null) ? double.Parse(scores[i]) : 0; var minEt = double.Parse(minElutionTime[i]); var maxEt = double.Parse(maxElutionTime[i]); var minNet = minEt / run.GetElutionTime(run.MaxLcScan); var maxNet = maxEt / run.GetElutionTime(run.MaxLcScan); var feature = new LcMsFeature(repMass, repCharge, repMz, repScanNum, abundance, minCharge, maxCharge, minScan, maxScan, minEt, maxEt, minNet, maxNet) { FeatureId = fid, DataSetId = dataId, Score = score, }; featureList.Add(feature); } return(featureList); }
private double NetDiff(LcMsFeature f1, LcMsFeature f2) { var n1 = Math.Abs(f1.Net - f2.Net); return(n1); //var n2 = Math.Abs(f1.MinNet - f2.MinNet); //var n3 = Math.Abs(f1.MaxNet - f2.MaxNet); //return Math.Min(Math.Min(n1, n2), n3); }
public double CoElutionNetLength(LcMsFeature other) { if (other.MaxNet >= MinNet && other.MaxNet <= MaxNet) { return(other.MaxNet - Math.Max(MinNet, other.MinNet)); } if (MaxNet >= other.MinNet && MaxNet <= other.MaxNet) { return(MaxNet - Math.Max(other.MinNet, MinNet)); } return(0d); }
public double CoElutionLength(LcMsFeature other) { if (other.MaxScanNum >= MinScanNum && other.MaxScanNum <= MaxScanNum) { return(other.MaxElutionTime - Math.Max(MinElutionTime, other.MinElutionTime)); } if (MaxScanNum >= other.MinScanNum && MaxScanNum <= other.MaxScanNum) { return(MaxElutionTime - Math.Max(other.MinElutionTime, MinElutionTime)); } return(0d); }
private List <LcMsFeature[]> GroupFeatures(List <LcMsFeature> features) { var adjList = new List <int> [features.Count]; for (var i = 0; i < features.Count; i++) { adjList[i] = new List <int>(); } for (var i = 0; i < features.Count; i++) { var fi = features[i]; for (var j = i + 1; j < features.Count; j++) { var fj = features[j]; if (fj.Mass - fi.Mass > 1.5) { break; } if (_featureCompare.SameCluster(fi, fj)) { adjList[i].Add(j); adjList[j].Add(i); } } } var ret = new List <LcMsFeature[]>(); var components = GetConnectedComponents(adjList); for (var i = 0; i < components.Count; i++) { var component = new HashSet <int>(components[i]); while (component.Count > 0) { var featureGroup = new LcMsFeature[CountDatasets]; var featureSet = GetAlignedFeatures(ref component, adjList); foreach (var f in featureSet) { featureGroup[f.DataSetId] = f; } ret.Add(featureGroup); } } return(ret); }
public bool CoElutedByNet(LcMsFeature other, double tolNet = 0d) { if (MinNet - tolNet < other.MinNet && other.MinNet < MaxNet + tolNet) { return(true); } if (MinNet - tolNet < other.MaxNet && other.MaxNet < MaxNet + tolNet) { return(true); } if (other.MinNet - tolNet < MinNet && MinNet < other.MaxNet + tolNet) { return(true); } if (other.MinNet - tolNet < MaxNet && MaxNet < other.MaxNet + tolNet) { return(true); } return(false); }
public bool CoElutedByTime(LcMsFeature other, double tolTime = 0d) { if (MinElutionTime - tolTime < other.MinElutionTime && other.MinElutionTime < MaxElutionTime + tolTime) { return(true); } if (MinElutionTime - tolTime < other.MaxElutionTime && other.MaxElutionTime < MaxElutionTime + tolTime) { return(true); } if (other.MinElutionTime - tolTime < MinElutionTime && MinElutionTime < other.MaxElutionTime + tolTime) { return(true); } if (other.MinElutionTime - tolTime < MaxElutionTime && MaxElutionTime < other.MaxElutionTime + tolTime) { return(true); } return(false); }
public static string GetString(LcMsFeature feature) { // should be called after calling UpdateScore & UpdateAbundance var sb = new StringBuilder(string.Format("{0}\t{1}\t{2}\t{3}\t{4:0.0000}\t{5}\t{6}\t{7:0.0000}\t{8:0.00}", feature.MinScanNum, feature.MaxScanNum, feature.MinCharge, feature.MaxCharge, feature.RepresentativeMass, feature.RepresentativeScanNum, feature.RepresentativeCharge, feature.RepresentativeMz, feature.Abundance)); sb.AppendFormat("\t{0:0}", 0); sb.AppendFormat("\t{0:0.00}", 0); sb.AppendFormat("\t{0:0.0}", feature.MinElutionTime); sb.AppendFormat("\t{0:0.0}", feature.MaxElutionTime); sb.AppendFormat("\t{0:0.0}", feature.ElutionLength); sb.Append("\t"); sb.Append(""); sb.Append(string.Format("\t{0:0.0}", feature.Score)); return sb.ToString(); }
public ProteinSpectrumMatch FindByFeature(LcMsFeature feature, Tolerance tolerance) { return(FindByFeature(feature.Mass, feature.MinScanNum, feature.MaxScanNum, tolerance)); }
public ProteinSpectrumMatch FindByFeature(LcMsFeature feature, Tolerance tolerance) { return FindByFeature(feature.Mass, feature.MinScanNum, feature.MaxScanNum, tolerance); }
public double CoElutionLength(LcMsFeature other) { if (other.MaxScanNum >= MinScanNum && other.MaxScanNum <= MaxScanNum) { return (other.MaxElutionTime - Math.Max(MinElutionTime, other.MinElutionTime)); } if (MaxScanNum >= other.MinScanNum && MaxScanNum <= other.MaxScanNum) { return (MaxElutionTime - Math.Max(other.MinElutionTime, MinElutionTime)); } return 0d; }
public bool CoElutedByScanNum(LcMsFeature other, int tolScan = 0) { if (tolScan == 0) tolScan++; if (MinScanNum - tolScan < other.MinScanNum && other.MinScanNum < MaxScanNum + tolScan) return true; if (MinScanNum - tolScan < other.MaxScanNum && other.MaxScanNum < MaxScanNum + tolScan) return true; if (other.MinScanNum - tolScan < MinScanNum && MinScanNum < other.MaxScanNum + tolScan) return true; if (other.MinScanNum - tolScan < MaxScanNum && MaxScanNum < other.MaxScanNum + tolScan) return true; return false; }
public bool CoElutedByNet(LcMsFeature other, double tolNet = 0d) { if (MinNet - tolNet < other.MinNet && other.MinNet < MaxNet + tolNet) return true; if (MinNet - tolNet < other.MaxNet && other.MaxNet < MaxNet + tolNet) return true; if (other.MinNet - tolNet < MinNet && MinNet < other.MaxNet + tolNet) return true; if (other.MinNet - tolNet < MaxNet && MaxNet < other.MaxNet + tolNet) return true; return false; }
public bool CoElutedByTime(LcMsFeature other, double tolTime = 0d) { if (MinElutionTime - tolTime < other.MinElutionTime && other.MinElutionTime < MaxElutionTime + tolTime) return true; if (MinElutionTime - tolTime < other.MaxElutionTime && other.MaxElutionTime < MaxElutionTime + tolTime) return true; if (other.MinElutionTime - tolTime < MinElutionTime && MinElutionTime < other.MaxElutionTime + tolTime) return true; if (other.MinElutionTime - tolTime < MaxElutionTime && MaxElutionTime < other.MaxElutionTime + tolTime) return true; return false; }
public double CoElutionNetLength(LcMsFeature other) { if (other.MaxNet >= MinNet && other.MaxNet<= MaxNet) { return (other.MaxNet - Math.Max(MinNet, other.MinNet)); } if (MaxNet >= other.MinNet && MaxNet <= other.MaxNet) { return (MaxNet - Math.Max(other.MinNet, MinNet)); } return 0d; }