Esempio n. 1
0
        public static bool TryGetMatrixFromSequenceFileAndPossiblyConvertDna2Aa <TRow, TCol, TVal>(string filename, TVal missing, bool keepOneValueVariables, ParallelOptions parallelOptions, out Matrix <TRow, TCol, TVal> matrix)
        {
            SequenceFormatter formatter;

            matrix = null;
            if (SequenceFormatter.TryGetLikelyFormatterForFile(filename, out formatter))
            {
                // only support true sequence formats.
                if (formatter is SequenceMatrix)
                {
                    return(false);
                }

                var seqs = formatter.Parse(filename);
                if (seqs.Count == 0)
                {
                    return(false);
                }

                if (seqs[0].IsDna())
                {
                    seqs = Translate(seqs, true);
                }

                matrix = NamedSequencesToMatrix <TRow, TCol, TVal>(seqs, missing, keepOneValueVariables, parallelOptions);
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public static bool TryGetMatrixFromSequenceFile <TRow, TCol, TVal>(string filename, TVal missing, bool keepOneValueVariables, ParallelOptions parallelOptions, out Matrix <TRow, TCol, TVal> matrix)
        {
            SequenceFormatter formatter;

            matrix = null;
            if (SequenceFormatter.TryGetLikelyFormatterForFile(filename, out formatter))
            {
                // only support true sequence formats.
                if (formatter is SequenceMatrix)// || formatter is SequenceFormatterSparse)
                {
                    return(false);
                }

                var seqs = formatter.Parse(filename);
                if (seqs.Count == 0)
                {
                    Console.Error.WriteLine("No sequences in sequence file of format {0}", formatter.FileFormat);
                    return(false);
                }
                matrix = NamedSequencesToMatrix <TRow, TCol, TVal>(seqs, missing, keepOneValueVariables, parallelOptions);
                return(true);
                //if (IsDna(seqs[0].Sequence))
                //{
                //    seqs = NucSeqToAaSeq(seqs, true);
                //}
            }
            Console.Error.WriteLine("No SequenceFormatter matches this file type.");
            return(false);
        }