/// <summary> /// Determine equality (by Id) of two ILinearDomain objects. /// </summary> /// <param name="other"> /// An object that implements ILinearDomain against which this object is to be /// compared. /// </param> /// <returns> /// Returns true if and only if the respective Id fields of this object and the /// comparison object are equal. /// </returns> public bool Equals(ILinearDomain other) { return(CompareTo(other) == 0); }
/// <summary> /// Loads the contents of a list of blast result collator objects into the model. /// <para> /// When finished, fires the LoadComplete event to notify listeners. /// </para> /// </summary> public void Load(IList <BlastResultCollator> blastResults) { StringWriter errorLog = new StringWriter(); featureCollection.features.Clear(); featureCollection.hits.Clear(); featureCollection.sequences.Clear(); featureCollection.initialQuerySequence = null; foreach (BlastResultCollator blastResult in blastResults) { try { ILinearDomain querySequence = null; ILinearDomain hitSequence = null; string queryId = blastResult.QueryId == null ? String.Format(Resource.SILVERMAP_UNKNOWN_QUERY_ID, unknownQuerySerialNumber ++) : blastResult.QueryId; string subjectId = blastResult.SubjectId == null ? blastResult.Accession : blastResult.SubjectId; if (featureCollection.sequences.ContainsKey(queryId)) { querySequence = featureCollection.sequences[queryId]; } else { querySequence = new SilverMapSequence( queryId, Resource.SILVERMAP_QUERY_SEQUENCE, queryId, blastResult.Length ); featureCollection.sequences.Add(queryId, querySequence); } if (featureCollection.initialQuerySequence == null) { featureCollection.initialQuerySequence = querySequence; } featureCollection.querySequences.Add(querySequence); if (featureCollection.sequences.ContainsKey(subjectId)) { hitSequence = featureCollection.sequences[subjectId]; } else { hitSequence = new SilverMapSequence( subjectId, blastResult.Description, subjectId, blastResult.Length ); featureCollection.sequences.Add(subjectId, hitSequence); } long queryStart = Math.Min(blastResult.QStart, blastResult.QEnd); long queryEnd = Math.Max(blastResult.QStart, blastResult.QEnd); DefaultFeature queryFeature = new DefaultFeature( querySequence, queryStart, queryEnd, blastResult.QueryString ); long subjectStart = Math.Min(blastResult.SStart, blastResult.SEnd); long subjectEnd = Math.Max(blastResult.SStart, blastResult.SEnd); DefaultFeature hitFeature = new DefaultFeature( hitSequence, subjectStart, subjectEnd, blastResult.SubjectString ); featureCollection.features.Add(queryFeature); featureCollection.features.Add(hitFeature); featureCollection.hits.Add(new Hit(queryFeature, hitFeature) { EValue = blastResult.EValue, Identities = blastResult.Identity, Midline = Hit.SEQUENCE_DATA_UNAVAILABLE, Positives = blastResult.Positives }); } catch (Exception e) { errorLog.WriteLine(String.Format(Resource.SILVERMAP_ERROR_PROCESSING_BLAST_RESULT, e)); } } if (errorLog.GetStringBuilder().Length > 0) { MessageDialogBox.Show(errorLog.ToString(), Resource.CAPTION, MessageDialogButton.OK); } SignalLoadComplete(); }
/// <summary> /// Compare this sequence to another, based on Id. /// </summary> /// <param name="other"> /// An object that implements ILinearDomain against which this object is to be /// compared. /// </param> /// <returns> /// Returns the result obtained by comparing the Id of this sequence with that of /// the comparison sequence. /// </returns> public int CompareTo(ILinearDomain other) { return(id.CompareTo(other.Id)); }