示例#1
0
        public YSTRLib(string input_vcf_gz)
        {
            _input_vcf_gz = input_vcf_gz;
            string exe_path = @"bin\ubin\";//Path.GetTempPath();

            bcftools_exe = exe_path + "bcftools.exe";

            //if (!File.Exists(bcftools_exe))
            //    File.WriteAllBytes(bcftools_exe, Y_STR_Finder.Properties.Resources.bcftools_exe);
            //if (!File.Exists(exe_path + "cygwin1.dll"))
            //    File.WriteAllBytes(exe_path + "cygwin1.dll", Y_STR_Finder.Properties.Resources.cygwin1_dll);
            //if (!File.Exists(exe_path + "cygz.dll"))
            //    File.WriteAllBytes(exe_path + "cygz.dll", Y_STR_Finder.Properties.Resources.cygz_dll);
            _lib = this;
        }
示例#2
0
        // bin\bgzip.exe bam_chrY.vcf
        // bin\tabix.exe bam_chrY.vcf.gz
        // bin\bcftools.exe query -f '%POS\t[%TGT]\n' -r chrY:3131128-3131246 bam_chrY.vcf.gz > DYS393.txt

        static void Main(string[] args)
        {
            StringBuilder report = new StringBuilder();

            if (args.Length != 3)
            {
                Console.WriteLine("*** This program is not designed to work independently. Use it at your own risk ***");
                Console.WriteLine("ystrfinder.exe <ref> <in_vcf_bgz> <out_report_html>");
                return;
            }

            string yref_file   = args[0]; //"ystr_info.txt";
            string intput_file = args[1]; // @"C:\Genetics\Y-STR Kit\bam_chrY.vcf.gz";
            string out_file    = args[2];

            if (!File.Exists(yref_file) || !File.Exists(intput_file))
            {
                Console.WriteLine("input/ref does not exist!");
                return;
            }

            YSTRLib ylib = new YSTRLib(intput_file);

            string[] lines         = File.ReadAllLines(yref_file);
            string[] data          = null;
            string   ystr          = null;
            long     begin_pos     = 0;
            long     end_pos       = 0;
            string   regex_motif   = null;
            string   filter_motif  = null;
            string   replace_regex = null;

            String rpt_table_overview = Y_STR_Finder.Properties.Resources.ystr_overview;

            report.Append("<html><head><title>Y-STR Kit Report</title></head><body style='font-family:Calibri; Color:black; font-style:normal'><h1>Y-STR Kit Report</h1>");
            report.Append("@TABLE@");
            foreach (string line in lines)
            {
                if (line.StartsWith("#") || line.Trim() == "")
                {
                    continue;
                }

                data = line.Split(new char[] { '\t' });

                if (data[0].StartsWith("TITLE"))
                {
                    report.Append("<h2>" + data[1] + "</h2>");
                    continue;
                }

                ystr = data[0];

                begin_pos     = long.Parse(data[1]);
                end_pos       = long.Parse(data[2]);
                regex_motif   = data[3];
                filter_motif  = data[4];
                replace_regex = data[5];

                YStrResult result = ylib.getYSTR(begin_pos, end_pos, regex_motif, filter_motif, replace_regex);
                //Console.WriteLine(ystr + " = " + result.value+"\t["+result.reliability+"]");
                report.Append("<a name='" + ystr + "'></a>");
                report.Append("<h3>" + ystr + " = " + result.value + "</h3>");
                report.Append("<i>Location: ChrY:" + begin_pos + "-" + end_pos + "</i><br>");
                report.Append("<div style='width:600px; padding:10px;word-wrap: break-word;color:#909090;font-family: monospace;'>" + result.html_seq + "</div>");
                report.Append("<i>Reliability is " + result.reliability + "%</i><br><br>");

                rpt_table_overview = rpt_table_overview.Replace("@" + ystr + "@", result.value.ToString());

                if (result.reliability == 100)
                {
                    rpt_table_overview = rpt_table_overview.Replace("@" + ystr + "_COLOR@", "green");
                }
                else
                {
                    rpt_table_overview = rpt_table_overview.Replace("@" + ystr + "_COLOR@", "red");
                }

                //Console.WriteLine(result.raw_seq);
                //Console.WriteLine();
            }



            report.Append("<i>Report generated by <a href='http://www.y-str.org/'>Y-STR Kit</a>.</i>");
            report.Append("</body></html>");

            string final_report = report.ToString();

            final_report = final_report.Replace("@TABLE@", rpt_table_overview);

            File.WriteAllText(out_file, final_report);
        }