Exemplo n.º 1
0
        /// <summary>
        /// Performs Stage 1, 2, and 3 as described in class description.
        /// </summary>
        /// <param name="inputSequences">Input sequences</param>
        /// <returns>Alignment results</returns>
        public IList <Alignment.ISequenceAlignment> Align(IEnumerable <ISequence> inputSequences)
        {
            // Reset all our data in case this same instance is used multiple times.
            _alignedSequences = _alignedSequencesA = _alignedSequencesB = _alignedSequencesC = null;
            _alignmentScore   = _alignmentScoreA = _alignmentScoreB = _alignmentScoreC = float.MinValue;

            // Get our list of sequences.
            List <ISequence> sequences = inputSequences.ToList();

            if (sequences.Count == 0)
            {
                throw new ArgumentException("Empty input sequences");
            }

            // Assign the gap open/extension cost if it hasn't been assigned.
            if (GapOpenCost == 0)
            {
                GapOpenCost = -4;
            }
            if (GapExtensionCost == 0)
            {
                GapExtensionCost = -1;
            }

            Performance.Start();

            // Assign the alphabet
            SetAlphabet(sequences, SimilarityMatrix, true);
            MsaUtils.SetProfileItemSets(_alphabet);

            Performance.Snapshot("Start Aligning");

            // Work...
            DoAlignment(sequences);

            // just for the purpose of integrating PW and MSA with the same output
            var alignment = new Alignment.SequenceAlignment();
            IAlignedSequence aSequence = new AlignedSequence();

            foreach (var alignedSequence in AlignedSequences)
            {
                aSequence.Sequences.Add(alignedSequence);
            }
            foreach (var inputSequence in sequences)
            {
                alignment.Sequences.Add(inputSequence);
            }
            alignment.AlignedSequences.Add(aSequence);
            return(new List <Alignment.ISequenceAlignment>()
            {
                alignment
            });
        }
        /// <summary>
        /// Performs Stage 1, 2, and 3 as described in class description.
        /// </summary>
        /// <param name="inputSequences">Input sequences</param>
        /// <returns>Alignment results</returns>
        public IList<Alignment.ISequenceAlignment> Align(IEnumerable<ISequence> inputSequences)
        {
            // Reset all our data in case this same instance is used multiple times.
            this.AlignedSequences = this.AlignedSequencesA = this.AlignedSequencesB = this.AlignedSequencesC = null;
            this.AlignmentScore = this.AlignmentScoreA = this.AlignmentScoreB = this.AlignmentScoreC = float.MinValue;

            // Get our list of sequences.
            List<ISequence> sequences = inputSequences.ToList();
            if (sequences.Count == 0)
            {
                throw new ArgumentException("Empty input sequences");
            }

            // Assign the gap open/extension cost if it hasn't been assigned.
            if (GapOpenCost == 0)
                GapOpenCost = -4;
            if (GapExtensionCost == 0)
                GapExtensionCost = -1;

            StartLog();

            // Assign the alphabet
            SetAlphabet(sequences, SimilarityMatrix, true);
            MsaUtils.SetProfileItemSets(this.alphabet);

            ReportLog("Start Aligning");

            // Work...
            DoAlignment(sequences);

            // just for the purpose of integrating PW and MSA with the same output
            var alignment = new Alignment.SequenceAlignment();
            IAlignedSequence aSequence = new AlignedSequence();
            foreach (var alignedSequence in AlignedSequences)
                aSequence.Sequences.Add(alignedSequence);
            foreach (var inputSequence in sequences)
                alignment.Sequences.Add(inputSequence);
            alignment.AlignedSequences.Add(aSequence);
            return new List<Alignment.ISequenceAlignment>() {alignment};
        }