static public Middle GetInstance(IHashableFeature feature) { Middle middle = new Middle(); middle.FeatureCollection = new Feature[] { (Feature)feature }; return(middle); }
//!!!make work for any number of arguments public And(IHashableFeature boolfeature1, IHashableFeature boolfeature2) { if (boolfeature1 != null && boolfeature2 != null) { base.FeatureCollection = new Feature[] { (Feature)boolfeature1, (Feature)boolfeature2 }; } }
static public End GetInstance(IHashableFeature feature) { End end = new End(); end.FeatureCollection = new Feature[] { (Feature)feature }; return(end); }
static public Begin GetInstance(IHashableFeature feature) { Begin begin = new Begin(); begin.FeatureCollection = new Feature[] { (Feature)feature }; return(begin); }
private static IEnumerable <IHashableFeature> BegMiddleEndOfPeptide(IHashableFeature regionFeature) { yield return(Begin.GetInstance(regionFeature)); yield return(Middle.GetInstance(regionFeature)); yield return(End.GetInstance(regionFeature)); }
static public In GetInstance(string aaSeq, IHashableFeature feature) { In inFeature = new In(); inFeature.AASeq = aaSeq; inFeature.FeatureCollection = new Feature[] { (Feature)feature }; return(inFeature); }
static public InProperty GetInstance(string propertySeq, IHashableFeature subFeature) { InProperty feature = new InProperty(); feature.PropertySeq = propertySeq; feature.FeatureCollection = new Feature[] { (Feature)subFeature }; return(feature); }
static public SubSeq GetInstance(int posLo, int posHi, bool fromLeft, IHashableFeature feature) { SubSeq subSeq = new SubSeq(); subSeq.PosLo = posLo; subSeq.PosHi = posHi; subSeq.FromLeft = fromLeft; subSeq.FeatureCollection = new Feature[] { (Feature)feature }; return(subSeq); }
private static IEnumerable <IHashableFeature> FromOneByOne(IHashableFeature regionFeature, bool fromLeft, int length, object entity) { string region = (string)((Feature)regionFeature).Evaluate(entity); for (int aa1Lo = 1; aa1Lo <= region.Length - length + 1; ++aa1Lo) { SubSeq subSeq = SubSeq.GetInstance(aa1Lo, aa1Lo + length - 1, fromLeft, regionFeature); yield return(subSeq); } }
internal static IsAA GetInstance(string aminoAcid, IHashableFeature featureE) { IsAA isAA = new IsAA(); isAA.AminoAcid = aminoAcid; if (featureE != null) { isAA.FeatureCollection = new Feature[] { (Feature)featureE }; } return(isAA); }
internal static HasAAProp GetInstance(string property, IHashableFeature featureE) { HasAAProp hasAAProp = new HasAAProp(); hasAAProp.Prop = property; if (featureE != null) { hasAAProp.FeatureCollection = new Feature[] { (Feature)featureE }; } return(hasAAProp); }
private static void AddFeatureWithOptionalAndHlaAndST(IHashableFeature feature, bool includeAndHlaAndST, IEnumerable <IHashableFeature> hlaishEnumeration, bool checkThatNew, ref Set <IHashableFeature> featureSet) { featureSet.Add(feature, checkThatNew); if (includeAndHlaAndST) { foreach (IHashableFeature hlaishFeature in hlaishEnumeration) { And featureAndHlaish = And.GetInstance(hlaishFeature, feature); featureSet.Add(featureAndHlaish, checkThatNew); } } }
private static void AddEiFeatures(bool includeChemicalProperties, bool includeAAFeatures, bool substractChemAACrissCrossFeatures, NEC nec, Pair <NEC, Hla> necAndHla, Set <IHashableFeature> hlaishFeatureSet, Set <IHashableFeature> featureSet) { for (int i = 0; i < nec.E.Length; ++i) { IHashableFeature featureE = E.GetInstance(i + 1); string aminoAcid = GetAminoAcidFromEpitopePosition(nec, i); if (includeAAFeatures) { IsAA featureAA = IsAA.GetInstance(aminoAcid, featureE); featureSet.AddNew(featureAA); Debug.Assert((bool)featureAA.Evaluate(necAndHla)); // real assert - must only generate true features foreach (IHashableFeature hlaishFeature in hlaishFeatureSet) { if (substractChemAACrissCrossFeatures && hlaishFeature is HasAAProp) { continue; } And featureHlaishAndAA = And.GetInstance(hlaishFeature, featureAA); featureSet.AddNew(featureHlaishAndAA); Debug.Assert((bool)featureHlaishAndAA.Evaluate(necAndHla)); // real assert - must only generate true features } } if (includeChemicalProperties) { foreach (string property in VirusCount.KmerProperties.AaToPropList[aminoAcid]) { HasAAProp featureAAProp = HasAAProp.GetInstance(property, featureE); featureSet.AddNew(featureAAProp); Debug.Assert((bool)featureAAProp.Evaluate(necAndHla)); // real assert - must only generate true features foreach (IHashableFeature hlaishFeature in hlaishFeatureSet) { if (substractChemAACrissCrossFeatures && hlaishFeature is IsAA) { continue; } And featureHlaishAndAAProb = And.GetInstance(hlaishFeature, featureAAProp); featureSet.AddNew(featureHlaishAndAAProb); Debug.Assert((bool)featureHlaishAndAAProb.Evaluate(necAndHla)); // real assert - must only generate true features } } } } //All of the above with AA replaced by chemical property of AA }
//public static IEnumerable<IHashableFeature> GetInSubSeqEnumeration(IHashableFeature regionFeature, // bool fromLeft, IEnumerable<KeyValuePair<int, int>> startAndEndEnumeration, object entity, int littleLength) //{ // foreach (KeyValuePair<int, int> startAndEnd in startAndEndEnumeration) // { // SubSeq subSeq = SubSeq.GetInstance(startAndEnd.Key, startAndEnd.Value, fromLeft, regionFeature); // string aaSeqFull = (string)subSeq.Evaluate(entity); // foreach (string aaSeqLittle in SpecialFunctions.SubstringEnumeration(aaSeqFull, littleLength)) // { // In inFeature = In.GetInstance(aaSeqLittle, subSeq); // Debug.Assert((bool)inFeature.Evaluate(entity)); // real assert - must only generate true features // yield return inFeature; // } // } //} public static IEnumerable <IHashableFeature> GetInSubSeqEnumeration(IHashableFeature regionFeature, bool fromLeft, Converter <IHashableFeature, IEnumerable <IHashableFeature> > regionFeatureToSubSeqEnumeration, object entity, int littleLength) { foreach (IHashableFeature epitopeSubSeq in regionFeatureToSubSeqEnumeration(regionFeature)) { string aaSeqFull = (string)((Feature)epitopeSubSeq).Evaluate(entity); foreach (string aaSeqLittle in SpecialFunctions.SubstringEnumeration(aaSeqFull, littleLength)) { In inFeature = In.GetInstance(aaSeqLittle, epitopeSubSeq); Debug.Assert((bool)inFeature.Evaluate(entity)); // real assert - must only generate true features yield return(inFeature); } } }
public static IEnumerable <IHashableFeature> GetInPropertySubSeqEnumeration(IHashableFeature regionFeature, bool fromLeft, IEnumerable <IHashableFeature> epitopeSubSeqEnumeration, Pair <NEC, Hla> entity, int littleLength) { foreach (IHashableFeature epitopeSubSeq in epitopeSubSeqEnumeration) { string aaSeqFull = (string)((Feature)epitopeSubSeq).Evaluate(entity); foreach (string aaSeqLittle in SpecialFunctions.SubstringEnumeration(aaSeqFull, littleLength)) { foreach (List <string> propertyCombination in KmerProperties.EveryPropertyCombination(aaSeqLittle)) { string propertySeq = SpecialFunctions.Join(",", propertyCombination); InProperty feature = InProperty.GetInstance(propertySeq, epitopeSubSeq); Debug.Assert((bool)feature.Evaluate(entity)); // real assert - must only generate true features yield return(feature); } } } }
static public List <WeightIf> GetWeights(List <IHashableFeature> featureSet, string weightsFile) { List <WeightIf> weightIfCollection = new List <WeightIf>(); bool seenOffset = false; using (StreamReader streamreaderWeights = File.OpenText(weightsFile)) { string sExpectedStart = "*Added feature "; //!!!const string sLineWeightsStart = streamreaderWeights.ReadLine(); SpecialFunctions.CheckCondition(sLineWeightsStart.StartsWith(sExpectedStart)); //!!!raise error int cFeature = 1 + int.Parse(sLineWeightsStart.Substring(sExpectedStart.Length)); //!!!could raise error SpecialFunctions.CheckCondition(cFeature == 1 + featureSet.Count, string.Format("Expected contant feature to be feature #{0} features in weight file, but it is {1}. File: {2}", featureSet.Count + 1, cFeature, weightsFile)); //!!!raise error for (int iFeature = 0; iFeature < cFeature; ++iFeature) { string sLineWeight = streamreaderWeights.ReadLine(); SpecialFunctions.CheckCondition(sLineWeight != null); //!!! raise error double rWeight = ParseWeight(sLineWeight, iFeature); if (iFeature + 1 < cFeature) { if (rWeight != 0) { IHashableFeature aFeature = featureSet[iFeature]; WeightIf aWeightIf = new WeightIf(rWeight, (Feature)aFeature); weightIfCollection.Add(aWeightIf); } } else { seenOffset = true; IHashableFeature aFeature = Logistic.AlwaysTrue; WeightIf aWeightIf = new WeightIf(rWeight, (Feature)aFeature); weightIfCollection.Add(aWeightIf); } } SpecialFunctions.CheckCondition(null == streamreaderWeights.ReadLine()); //!!! raise error } SpecialFunctions.CheckCondition(seenOffset); //!!!raise error return(weightIfCollection); }
public static IEnumerable <IHashableFeature> GetPropertySeqInRegionInstance(int k, Pair <NEC, Hla> necAndHla, IHashableFeature regionFeature) { NEC nec = necAndHla.First; string region = (string)((Feature)regionFeature).Evaluate(necAndHla); Set <string> aaSeqSet = Set <string> .GetInstance(SpecialFunctions.SubstringEnumeration(region, k)); foreach (string aaSeq in aaSeqSet) { foreach (List <string> propertyCombination in KmerProperties.EveryPropertyCombination(aaSeq)) { string propertySeq = SpecialFunctions.Join(",", propertyCombination); InProperty feature = InProperty.GetInstance(propertySeq, regionFeature); Debug.Assert((bool)feature.Evaluate(necAndHla)); // real assert - must only generate true features yield return(feature); } } }
public static IEnumerable <IHashableFeature> GetInPropertySubSeqEnumeration(IHashableFeature regionFeature, bool fromLeft, int length, Pair <NEC, Hla> entity) { return(GetInPropertySubSeqEnumeration(regionFeature, fromLeft, FromOneByOne(regionFeature, fromLeft, length, entity), entity, length)); }
public static IEnumerable <IHashableFeature> GetInSubSeqEnumeration(IHashableFeature regionFeature, bool fromLeft, int length, object entity) { return(GetInSubSeqEnumeration(regionFeature, fromLeft, delegate(IHashableFeature regionFeatureX) { return FromOneByOne(regionFeatureX, fromLeft, length, entity); }, entity, length)); }
public static IEnumerable <IHashableFeature> GetAASeqInRegionInstance(int k, object entity, IHashableFeature regionFeature) { string region = (string)((Feature)regionFeature).Evaluate(entity); Set <string> aaSeqSet = Set <string> .GetInstance(SpecialFunctions.SubstringEnumeration(region, k)); foreach (string aaSeq in aaSeqSet) { In inFeature = In.GetInstance(aaSeq, regionFeature); Debug.Assert((bool)inFeature.Evaluate(entity)); // real assert - must only generate true features yield return(inFeature); } }
//!!!make work for any number of arguments public static And GetInstance(IHashableFeature boolfeature1, IHashableFeature boolfeature2) { return(new And(boolfeature1, boolfeature2)); }