public void AddSiteFeature(SiteFeature feature) { collection.Add(feature); }
/** * Fetches data from GeneCollection and CodingSequenceCollection. * @returns siteFeatureCollection containing SiteFeature objects. */ public SiteFeatureCollection FetchSiteFeatures(GeneCollection geneCollection, CodingSequenceCollection cdsCollection, string[] featureCoordinateArray) { SiteFeatureCollection siteFeatureCollection = new SiteFeatureCollection(); List <string> nonMatchedFeatures = new List <string>(); foreach (string coordinate in featureCoordinateArray) { bool isMatch = false; if (Regex.IsMatch(coordinate, "\\d*\\.\\.\\d*")) { string[] split = Regex.Split(coordinate, "\\.\\."); int startCoordinate = Int32.Parse(split[0]); int endCoordinate = Int32.Parse(split[1]); for (int i = 0; i < geneCollection.collection.Count; i++) { string geneId = ""; string type = ""; string orientation = ""; Gene gene = geneCollection.collection[i]; CodingSequence cds = cdsCollection.collection[i]; if (gene.StartCoordinate >= startCoordinate && gene.EndCoordinate <= endCoordinate) { if (gene.ID != "") { geneId = gene.ID; } else { geneId = gene.LocusTag; } type = "gene"; int geneStartCoordinate = gene.StartCoordinate; int geneStopCoordinate = gene.EndCoordinate; if (gene.IsReverse) { orientation = "R"; } else { orientation = "F"; } SiteFeature feature = new SiteFeature(geneId, type, geneStartCoordinate, geneStopCoordinate, orientation); siteFeatureCollection.AddSiteFeature(feature); //Change type and change geneId to geneProduct for a CDS entry. Other values are similar to Gene values. string product = cds.GeneProduct; type = "CDS"; feature = new SiteFeature(product, type, geneStartCoordinate, geneStopCoordinate, orientation); siteFeatureCollection.AddSiteFeature(feature); isMatch = true; } } if (!isMatch) { nonMatchedFeatures.Add(coordinate); } } } if (!siteFeatureCollection.collection.Any() || !nonMatchedFeatures.Any()) { //Display list of site entries that did not match. String message = ""; foreach (String feature in nonMatchedFeatures) { if (message != "") { message += "Some of the provided enrties could not be found. Here is the list of sites; "; message += feature; } else { message += ", " + feature; } } Console.WriteLine("\n" + message); } siteFeatureCollection.Sort(); return(siteFeatureCollection); }