/** Tests the construction of a feature list */ public void TestConstructor () { Sequence seq = new Sequence( AlphabetType.DNA, "acgt" ); FeatureList featureList = new FeatureList( "Test" ); seq.AddFeatures( featureList ); Assert.AreEqual( 1, seq.FeatureLists.Count ); Assert.AreEqual( "Test", featureList.Name ); // Assert.AreEqual(seq, featureList.GetSequence()); }
public void TestGetFeatureSequence() { Sequence seq = new Sequence(AlphabetType.DNA, "acgta"); FeatureList featureList = new FeatureList("test"); Feature feature = new Feature("feature1", 2, 4, +1); featureList.Add(feature); seq.AddFeatures(featureList); Assert.AreEqual("cgt", feature.Letters()); }
/** Tests the adding of features */ public void TestAdd () { Sequence seq = new Sequence( AlphabetType.DNA, "acgt" ); FeatureList featureList = new FeatureList( "Test" ); seq.AddFeatures( featureList ); Feature feature1 = new Feature( "Test1", 1, 3, +1 ); Feature feature2 = new Feature( "Test2", 1, 3, +1 ); featureList.Add( feature1, false ); featureList.Add( feature2, true ); Assert.AreEqual( 2, featureList.Count ); Assert.AreEqual( null, feature1.BaseSequence ); Assert.AreEqual( seq, feature2.BaseSequence ); }
/** Tests the adding of feature lists */ public void TestAddList () { FeatureList featureList1 = new FeatureList( "Test" ); featureList1.Add( new Feature( "Test1", 1, 3, +1 ) ); featureList1.Add( new Feature( "Test2", 1, 3, +1 ) ); FeatureList featureList2 = new FeatureList( "Test" ); featureList2.Add( new Feature( "Test3", 1, 3, +1 ) ); featureList2.Add( new Feature( "Test4", 1, 3, +1 ) ); featureList1.Append( featureList2, true ); Assert.AreEqual( "Test1", featureList1[0].Name ); Assert.AreEqual( "Test2", featureList1[1].Name ); Assert.AreEqual( "Test3", featureList1[2].Name ); Assert.AreEqual( "Test4", featureList1[3].Name ); }
public List<Matched> PerformSearch(string BioPatMLContent, SequenceContract sequence) { List<Matched> matchedList = new List<Matched>(); StringReader sr = new StringReader(BioPatMLContent); Definition MyPatterns = null; using (BioPatMLPatternReader reader = new BioPatMLPatternReader()) { MyPatterns = reader.ReadBioPatML(sr); } Sequence targetSequence = new Sequence(sequence.AlphabetName, sequence.Characters); SequenceList matches = new FeatureList(); IPattern MatchingPattern = MyPatterns.MainPattern; #region If bioPatML pattern is SeriesBest OR SetBest : Search by best if (MatchingPattern is SeriesBest || MatchingPattern is SetBest) { Match match = targetSequence.SearchBest(0, 0, MatchingPattern); matches.Add(match); } #endregion #region Else, pattern is Motif, Any, Anchor, Prosite, RegularEx : Search by normal else //The rest { matches = targetSequence.Search(1, targetSequence.Length, MatchingPattern); } #endregion for (int i = 0; i < matches.Count; i++) { Match matched = matches[i] as Match; matchedList.Add(new Matched (matched.Similarity, matched.Start, matched.End, matched.Length, matched.Letters(), sequence.Name)); } return matchedList; }
/** Tests the getter of features */ public void TestFeature () { FeatureList featureList = new FeatureList( "Test" ); Feature feature1 = new Feature( "Test1", 1, 3, +1 ); Feature feature2 = new Feature( "Test2", 1, 3, +1 ); featureList.Add( feature1, false ); featureList.Add( feature2, true ); var t = featureList[ 0 ]; bool ans = feature1.Equals( featureList[0] ); Assert.IsTrue( feature1.Equals( featureList[0] ) ); Assert.IsTrue( feature2.Equals( featureList[1] ) ); Assert.IsTrue( feature2.Equals( featureList[-1] ) ); Assert.IsTrue( feature1.Equals( featureList[2] ) ); Assert.IsTrue( feature2.Equals( featureList[-3] ) ); Assert.IsTrue( feature1.Equals( featureList[4] ) ); Assert.IsTrue( feature1.Equals( featureList["Test1"] ) ); Assert.IsTrue( feature2.Equals( featureList["Test2"] ) ); }
/// <summary> /// Adds the features of the given list to the list. /// </summary> /// <param name="featureList"> A feature list.</param> /// <param name="setSequence"> <see> #add(Feature, boolean </see></param> public void Append(FeatureList featureList, bool setSequence) { for (int i = 0; i < featureList.Count; i++) Add(featureList.Feature(i), setSequence); }
/// <summary> /// Creates a feature list with all features of the sequences of the list /// which match the given feature name . /// </summary> /// <param name="featureListName"> /// Name of the feature lists which contain the features to extract. /// </param> /// <param name="featureName">Feature name.</param> /// <returns> /// Returns a feature list with all features which name matches the /// given feature name over all sequences of the sequence list. /// /// </returns> public FeatureList Features(String featureListName, String featureName) { FeatureList featureList = new FeatureList(featureListName); for (int i = 0; i < Count; i++) { FeatureList list = this[i].Features(featureListName); if (list != null) { for (int j = 0; j < list.Count; j++) { Feature feature = list.Feature(j); if (feature.AnnotationValue("Name").Equals(featureName)) featureList.Add(feature); } } } return (featureList); }
/// <summary> /// Setter for a match object on base of another match object. /// </summary> /// <param name="match">Match object with initial values.</param> public void Set(Match match) { Set(match.BaseSequence, match.Start, match.Length, match.Strand, match.Similarity); this.MatchPattern = match.MatchPattern; //this.Name = match.MatchPattern.PatternName; this.impact = match.impact; FeatureList subMatchList = match.SubMatchedList; if (subMatchList != null) { if (MatchedList == null) { FeatureList matchList = new FeatureList("SubMatches"); for (int i = 0; i < subMatchList.Count; i++) matchList.Add(Clone((Match)subMatchList.Feature(i))); MatchedList = matchList; } else { for (int i = 0; i < subMatchList.Count; i++) ((Match)MatchedList.Feature(i)).Set((Match)subMatchList.Feature(i)); } } else MatchedList = null; }
/** Tests the search for a feature which covers a given position */ public void TestInside () { Sequence seq = new Sequence( AlphabetType.DNA, "acgtactgactg" ); FeatureList featureList = new FeatureList( "Test" ); Feature feature1 = new Feature( "Test1", 2, 4, +1 ); Feature feature2 = new Feature( "Test2", 7, 10, +1 ); featureList.Add( feature1 ); featureList.Add( feature2 ); featureList.AttachSequence( seq ); Assert.AreEqual( feature1, featureList.Inside( seq, 2 ) ); Assert.AreEqual( feature1, featureList.Inside( seq, 4 ) ); Assert.AreEqual( null, featureList.Inside( seq, 1 ) ); Assert.AreEqual( null, featureList.Inside( seq, 5 ) ); Assert.AreEqual( feature2, featureList.Inside( seq, 7 ) ); Assert.AreEqual( feature2, featureList.Inside( seq, 10 ) ); Assert.AreEqual( null, featureList.Inside( seq, 6 ) ); Assert.AreEqual( null, featureList.Inside( seq, 11 ) ); }
/** Test getter for feature list name */ public void TestSetGetName () { FeatureList featureList = new FeatureList( "Test" ); Assert.AreEqual( "Test", featureList.Name ); }
public void TestAddGetFeature () { Sequence seq = new Sequence( AlphabetType.DNA, "ACTG" ); FeatureList flist1 = new FeatureList( "test1" ); FeatureList flist2 = new FeatureList( "test2" ); Assert.AreEqual( 0, seq.FeatureLists.Count ); seq.AddFeatures( flist1 ); seq.AddFeatures( flist2 ); Assert.AreEqual( 2, seq.FeatureLists.Count ); Assert.AreEqual( flist1, seq.FeatureLists[ 0 ] ); Assert.AreEqual( flist1, seq.FeatureLists[ "test1" ] ); Assert.AreEqual( flist2, seq.FeatureLists[ 1 ] ); Assert.AreEqual( flist2, seq.FeatureLists[ "test2" ] ); }
public void TestAddFeatureLists () { Sequence seq = new Sequence( AlphabetType.DNA, "ACTG" ); FeatureList flist1 = new FeatureList( "test1" ); FeatureList flist2 = new FeatureList( "test2" ); AnnotatedList<FeatureList> flists = new AnnotatedList<FeatureList>(); flists.Add( flist1 ); flists.Add( flist2 ); seq.AddFeatures( flists ); Assert.AreEqual( 2, seq.FeatureLists.Count ); }
/// <summary> /// This method transfers all available features from the MBF sequence and /// populate them into biopatml features data type. /// In this version only its name, start and end location is populated. /// </summary> /// <param name="metadata"></param> /// <returns></returns> private FeatureList ExtractFeatures(GenBankMetadata metadata) { List<FeatureItem> mbfFeatures = metadata.Features.All; FeatureList bioFeatureList = new FeatureList(); foreach (FeatureItem item in mbfFeatures) { #region Constructs the feature outline first //Strand is always assumed to be forward +1 QUT.Bio.BioPatML.Sequences.Feature bioFeature = new QUT.Bio.BioPatML.Sequences.Feature (item.Key, item.Location.Start, item.Location.End, 1); bioFeatureList.Add(bioFeature); #endregion #region Adds the qualifier key and values to Feature using AnnotationList AnnotationList annList = new AnnotationList(); foreach (KeyValuePair<string, List<string>> qualitfier in item.Qualifiers) annList.Add(qualitfier.Key, qualitfier.Value[0]); bioFeature.AddAnnotations(annList); #endregion } return bioFeatureList; }
/// <summary> /// Adds a feature list to the sequence. This attaches the feature list and /// all it's features to the sequence. Features which were attached to a /// different sequence before are then attached to the current sequence! /// </summary> /// <param name="featureList"> Feature list. </param> public void AddFeatures(FeatureList featureList) { Features().Add(featureList); featureList.AttachSequence(this); }