Example #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;
        }
Example #2
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 OutAglimentNcbi(string referenceName, string nucName, string nucs, string outAlignPath, ref string message)
        {
            SequenceProperties ncbidat = null;

            try {
                ncbidat = WfComponent.Utils.Genbank.GetSequenceProperties(referenceName, ref message);
                if (!string.IsNullOrEmpty(message) ||
                    ncbidat == null ||
                    string.IsNullOrEmpty(ncbidat.accession))
                {
                    message += "get genbank sequence data error. ";
                    return;  // genbank error
                }
            }
            catch (Exception e)
            {
                message += e.Message;
                return;
            }

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

            var fastaLines = new string[]
            {
                ">" + ncbidat.accession,
                ncbidat.sequence,
                ">" + 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;
        }