コード例 #1
0
        public static Matrix <TRow, TCol, TVal> NamedSequencesToMatrix <TRow, TCol, TVal>(List <NamedSequence> seqs, TVal missing, bool keepOneValueVariables, ParallelOptions parallelOptions)
        {
            Helper.CheckCondition(seqs.Count > 0, "There are no sequences");

            // can't do this because of the generics
            //var matrix = SequenceMatrix.ConvertToMatrix(seqs, MixtureSemantics.Uncertainty, SequenceMatrix.BinaryOrMultistate.Binary, keepOneValueVariables);
            string tempFile = Path.GetTempFileName();

            SequenceMatrix tableFormatter = new SequenceMatrix();

            tableFormatter.KeepOneValueVariables = keepOneValueVariables;
            ////if (keepOneValueVariables)
            ////{
            ////    tableFormatter.argumentCollection = new CommandArguments("-keepOneValueVariables");
            ////}
            tableFormatter.Write(seqs, tempFile);

            Matrix <TRow, TCol, TVal> matrix;
            bool success = DenseMatrix <TRow, TCol, TVal> .TryParseRFileWithDefaultMissing(tempFile, missing, parallelOptions, out matrix);

            File.Delete(tempFile);

            if (!success)
            {
                throw new Exception("Unexpected error parsing the table into a matrix. This exception should not happen.");
            }

            return(matrix);
        }
コード例 #2
0
        public static SequenceFormatter GetInstance(SequenceFileFormat format)
        {
            SequenceFormatter formatter = null;

            switch (format)
            {
            case SequenceFileFormat.Phylip:
                formatter = new Phylip();
                break;

            case SequenceFileFormat.Fasta:
                formatter = new Fasta();
                break;

            case SequenceFileFormat.Tab:
                formatter = new Tab();
                break;

            //case SequenceFileFormat.Sparse:
            //    formatter = new SequenceFormatterSparse();
            //    break;
            case SequenceFileFormat.Matrix:
                formatter = new SequenceMatrix();
                break;

            default:
                throw new Exception("Should never get here.");
            }
            formatter._formatType = format;

            return(formatter);
        }