Пример #1
0
        /// <summary>
        /// NCBI Reference nuc
        /// </summary>
        /// <param name="referenceName">NCBI Reference Accession </param>
        /// <param name="nucName">consensus name</param>
        /// <param name="nucs">consensus nucreotides</param>
        /// <param name="outAlignPath">output agliment file path</param>
        public static void OutAgliment(string referenceName, string nucName, string nucs, string outAlignPath, ref string message)
        {
            var mes       = string.Empty;
            var reference = SeveralUtils.GetCoronaReference(referenceName, ref mes);

            if (!string.IsNullOrEmpty(mes) ||
                string.IsNullOrEmpty(reference.Key) ||
                string.IsNullOrEmpty(reference.Value))
            {
                message += mes + Environment.NewLine;
                message += "alignment process error...";
                return;
            }



            var tmpFasta = outAlignPath.EndsWith(".fasta") ?
                           Path.ChangeExtension(outAlignPath, ".fna") :
                           Path.ChangeExtension(outAlignPath, ".fasta");

            var fastaLines = new string[]
            {
                ">" + reference.Key,
                reference.Value,
                ">" + nucName,
                nucs
            };

            // 一時Fasta
            WfComponent.Utils.FileUtils.WriteFile(tmpFasta, fastaLines, ref message);
            if (!string.IsNullOrEmpty(message))
            {
                return;
            }

            var alignProc = new WfComponent.External.Kalign(
                new WfComponent.External.KalignOptions()
            {
                fastaPath  = tmpFasta,
                outAlign   = outAlignPath,
                isFastaOut = true
            });

            // ほぼ一瞬で終わるはずなのでCancel 考えない。
            try
            {
                alignProc.StartProcess();
                message = alignProc.Message;

                if (File.Exists(outAlignPath))
                {
                    message = AliView.AliViewStart(outAlignPath);
                }
            }
            catch (Exception e)
            {
                message += e.Message;
                message += "execute agliment program error, " + alignProc.Message;
            }

            return;
        }
Пример #2
0
        public static void OutTree(string outTreePath, int sampleId, int topNo, ref string message)
        {
            // 当該サンプル情報
            var mes    = string.Empty;
            var sample = Dao.SampleDao.GetSample(sampleId, ref mes);

            if (!string.IsNullOrEmpty(mes) || sample == null || sample.ID <= 0)
            {
                message += mes;
                return;
            }

            var nucName       = sample.ViewName;
            var nucs          = GetDbValue(sample.Cns_Nucs, topNo);
            var referenceName = GetDbValue(sample.Accession, topNo);

            var reference = SeveralUtils.GetCoronaReference(referenceName, ref mes);

            if (!string.IsNullOrEmpty(mes) ||
                string.IsNullOrEmpty(reference.Key) ||
                string.IsNullOrEmpty(reference.Value))
            {
                message += mes + Environment.NewLine;
                message += "create tree process error...";
                return;
            }

            // for tree base fasta, to add reference , add consensus
            var baseTreeFasta = FileUtils.FindFile(
                Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\'),
                    referencesDir,
                    TreeReferenceDir),
                CommonFlow.covBaseName,
                FnaFooter);
            var coronaRefseq = baseTreeFasta.Any() ?
                               baseTreeFasta.First():
                               Path.Combine(                 // mapping reference
                FluGASv25.Proc.Flow.CommonFlow.GetMappingReferenceDir,
                CommonFlow.covBaseName + FnaFooter);



            var coronaRefseqLines = FileUtils.ReadFile(coronaRefseq, ref mes);
            var coronaReference   = new List <string>(coronaRefseqLines);

            coronaReference.Add(">" + reference.Key);
            coronaReference.Add(reference.Value);
            coronaReference.Add(">" + nucName);
            coronaReference.Add(nucs);


            var tmpFasta = outTreePath.EndsWith(".fasta") ?
                           Path.ChangeExtension(outTreePath, ".fna") :
                           Path.ChangeExtension(outTreePath, ".fasta");

            if (File.Exists(tmpFasta))
            {
                File.Delete(tmpFasta);
            }
            // 一時Fasta
            FileUtils.WriteFile(tmpFasta, coronaReference, ref message);
            if (!string.IsNullOrEmpty(message))
            {
                return;
            }


            var clustalO = new ClustalOmega(
                new ClustalOmegaOptions()
            {
                targetFile      = tmpFasta,
                outGuidTreeFile = outTreePath
            });

            try {
                var s = clustalO.StartProcess();
                if (!string.IsNullOrEmpty(s))
                {
                    message += s;
                }

                if (string.IsNullOrEmpty(clustalO.Message))
                {
                    message += clustalO.Message;
                }
            }
            catch (Exception e)
            {
                message += e.Message;
            }

            return;
        }