public void SetUp() { this.list = new AnnotationList(); }
/// <summary> /// Adds a list of annotations to the already existing annotations of the /// sequence. /// </summary> /// <param name="annotationList"> List of annotations to add. </param> public void AddAnnotations(AnnotationList annotationList) { if (annotationList != null) { AnnotationList a = Annotations(); for (int i = 0; i < annotationList.Count; i++) a.Add(annotationList[i]); } }
public void TestAddGetAnnotations () { Sequence seq = new Sequence( AlphabetType.DNA, "ACTG" ); AnnotationList a1 = seq.Annotations; Assert.AreEqual( 0, a1.Count ); AnnotationList a2 = new AnnotationList(); a2.Add( new Annotation( "name1", "value1" ) ); a2.Add( new Annotation( "name2", "value2" ) ); seq.Annotations.AddRange( a2 ); Assert.AreEqual( "name1", seq.Annotations[0].Name ); Assert.AreEqual( "value2", seq.Annotations[1].Value ); Assert.AreEqual( "name1", seq.Annotations[ "name1" ].Name ); Assert.AreEqual( "value2", seq.Annotations.Value( "name2" ) ); Assert.AreEqual( null, seq.Annotations.Value( "name3" ) ); Assert.AreEqual( null, seq.Annotations[ "name3" ] ); }
/// <summary> /// This method takes in a MBF sequence and converts it to BioPatML sequence. /// </summary> /// <param name="mbfseq">The MBF sequence one is interested in.</param> /// <returns>Returns the converted BioPatML sequence.</returns> public QUT.Bio.BioPatML.Sequences.Sequence ParseMBFSequence (Sequence mbfseq) { GenBankMetadata metaData; #region If sequence is complex type e.g. Genbank file with features if (mbfseq.Metadata.ContainsKey(Helper.GenBankMetadataKey)) { //Retrieves our meta data out metaData = (GenBankMetadata)mbfseq.Metadata[Helper.GenBankMetadataKey]; //Create our BioPatML sequence QUT.Bio.BioPatML.Sequences.Sequence bioSequence = new QUT.Bio.BioPatML.Sequences.Sequence (ParseAlphabet(mbfseq), mbfseq.ToString(), IsCircularStrand(metaData.Locus)); #region Top the BioPatML Sequence with Feature data and sequence name //Add features to sequence bioSequence.AddFeatures(ExtractFeatures(metaData)); //Add mbf sequence name to BioPatML sequence //Create annotation to put in our sequence data like name AnnotationList jacobiMeta = new AnnotationList(); jacobiMeta.Add("SequenceName", metaData.Locus.Name); bioSequence.AddAnnotations(jacobiMeta); #endregion return bioSequence; } #endregion #region Else we assume it is a simple type e.g. Fasta files else { QUT.Bio.BioPatML.Sequences.Sequence bioSequence = new QUT.Bio.BioPatML.Sequences.Sequence (ParseAlphabet(mbfseq), mbfseq.ToString(), false); AnnotationList jacobiMeta = new AnnotationList(); jacobiMeta.Add("SequenceName", mbfseq.DisplayID); bioSequence.AddAnnotations(jacobiMeta); return bioSequence; } #endregion }
/// <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> /// Gets all annotations which name matches the given regular expression. /// </summary> /// <param name="regExp"> /// Regular expression, <see> Pattern package </see> /// </param> /// <returns> /// Returns an annotation list with all annotations matching the given name. /// </returns> public AnnotationList GetAll(Regex regExp) { AnnotationList aList = new AnnotationList(); foreach (Annotation a in ListAnnotation) if (regExp.IsMatch(a.Name)) aList.Add(a); return (aList); }
/// <summary> /// Get all annotations with a given name. /// </summary> /// <param name="name"> Name of the annotations to retrieve. </param> /// <returns> /// Returns a of list annotations that matches the /// specified name. /// </returns> public AnnotationList GetAll(String name) { AnnotationList aList = new AnnotationList(); foreach (Annotation a in ListAnnotation) if(a.Name.Equals(name)) aList.Add(a); return aList; }
/// <summary> /// Getter for the list of annotations attached to the sequence. As soon as /// this method is called an empty annotation list will be attached to the /// sequence if none is existing before. /// </summary> /// <returns></returns> public AnnotationList Annotations() { if (ListAnnotations == null) ListAnnotations = new AnnotationList();; return (ListAnnotations); }