Exemple #1
0
        CreateNodeXLVennDiagramWorkbookFromSequenceRangeGroupings
            (
            Microsoft.Office.Interop.Excel.Application oApplication,
            SequenceRangeGrouping srgA,
            SequenceRangeGrouping srgB,
            SequenceRangeGrouping srgC
            )
        {
            SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_C, srgOnly_AB, srgOnly_AC, srgOnly_BC, srgOnly_ABC;
            CreateSequenceRangeGroupingsForVennDiagram(srgA
                , srgB
                , srgC
                , out srgOnly_A
                , out srgOnly_B
                , out srgOnly_C
                , out srgOnly_AB
                , out srgOnly_AC
                , out srgOnly_BC
                , out srgOnly_ABC);

            // generate the intersection Venn metrics
            SequenceRangeGroupingMetrics srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A);
            SequenceRangeGroupingMetrics srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B);
            SequenceRangeGroupingMetrics srgmOnly_C = new SequenceRangeGroupingMetrics(srgOnly_C);
            SequenceRangeGroupingMetrics srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB);
            SequenceRangeGroupingMetrics srgmOnly_AC = new SequenceRangeGroupingMetrics(srgOnly_AC);
            SequenceRangeGroupingMetrics srgmOnly_BC = new SequenceRangeGroupingMetrics(srgOnly_BC);
            SequenceRangeGroupingMetrics srgmOnly_ABC = new SequenceRangeGroupingMetrics(srgOnly_ABC);

            // create the NodeXL Venn diagram filefile
            VennDiagramData vdd = new VennDiagramData(srgmOnly_A.bases
                , srgmOnly_B.bases
                , srgmOnly_C.bases
                , srgmOnly_AB.bases
                , srgmOnly_AC.bases
                , srgmOnly_BC.bases
                , srgmOnly_ABC.bases);

            // To ensure NodeXL displays the diagram, DONOT make the application 
            // visible or update the screen until the parameters are all set up.
            oApplication.ScreenUpdating = false;
            Workbook oWorkbook = CreateNodeXLVennDiagramWorkbook(oApplication, vdd);

            // write source data to workbook
            DisplaySourceData(srgA, Resources.A, oWorkbook);
            DisplaySourceData(srgB, Resources.B, oWorkbook);
            DisplaySourceData(srgC, Resources.C, oWorkbook);

            // Write overlap data to a sheet
            Worksheet outputSheet = oWorkbook.Sheets.Add(Type.Missing, oWorkbook.Sheets[oWorkbook.Sheets.Count], 1, XlSheetType.xlWorksheet);
            outputSheet.Name = Resources.OverlapsSheetName;
            WriteOverlapData(outputSheet, srgOnly_A, srgOnly_B, srgOnly_C, srgOnly_AB, srgOnly_AC, srgOnly_BC, srgOnly_ABC);

            oApplication.ScreenUpdating = true;
            oApplication.Visible = true;
            return oWorkbook;
        }
Exemple #2
0
        CreateNodeXLVennDiagramWorkbookFromSequenceRangeGroupings
            (
            Microsoft.Office.Interop.Excel.Application oApplication,
            SequenceRangeGrouping srgA,
            SequenceRangeGrouping srgB
            )
        {
            // create the proper sets for VennDiagram
            SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_AB;
            CreateSequenceRangeGroupingsForVennDiagram(srgA, srgB, out srgOnly_A, out srgOnly_B, out srgOnly_AB);

            SequenceRangeGroupingMetrics srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A);
            SequenceRangeGroupingMetrics srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B);
            SequenceRangeGroupingMetrics srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB);

            VennDiagramData vdd = new VennDiagramData(srgmOnly_A.bases
                , srgmOnly_B.bases
                , srgmOnly_AB.bases);

            Workbook oWorkbook = CreateNodeXLVennDiagramWorkbook(oApplication, vdd);

            // write source data to workbook
            DisplaySourceData(srgA, Resources.A, oWorkbook);
            DisplaySourceData(srgB, Resources.B, oWorkbook);

            // Write overlap data to a sheet
            Worksheet outputSheet = oWorkbook.Sheets.Add(Type.Missing, oWorkbook.Sheets[oWorkbook.Sheets.Count], 1, XlSheetType.xlWorksheet);
            outputSheet.Name = Resources.OverlapsSheetName;
            WriteOverlapData(outputSheet, srgOnly_A, srgOnly_B, srgOnly_AB);

            oApplication.Visible = true;
            return oWorkbook;
        }
Exemple #3
0
        // default printing of SequenceRangeGrouping
        //
        public static void SequenceRangeGroupingToString(SequenceRangeGrouping srg, string name)
        {
            Console.Error.Write("[{0}] : SeqeuenceRangeGrouping: ", name);
            var srgm = new SequenceRangeGroupingMetrics(srg);
            Console.Error.WriteLine("{0}, {1}, {2}", srgm.groups, srgm.ranges, srgm.bases);

            foreach (string id in srg.GroupIDs)
            {
                Console.Error.WriteLine("--GroupID: {0}, {1}", id, srg.GetGroup(id).Count());
                ListSequenceRangeToString(srg.GetGroup(id));
            }
            Console.Error.WriteLine();
        }
Exemple #4
0
        public static int Main(string[] args)
        {
            try
            {
                Splash();
                arguments = ProcessCommandLineArguments(args);

                if (arguments.inputFiles.Count() == 2)
                {
                    // now read the 2 BED files and do the operation to isolate each set
                    SequenceRangeGrouping srg1 = ReadBedFile(arguments.inputFiles[0]);
                    SequenceRangeGrouping srg2 = ReadBedFile(arguments.inputFiles[1]);

                    SequenceRangeGrouping srgOnly_A, srgOnly_B, srgOnly_AB;

                    VennToNodeXL.CreateSequenceRangeGroupingsForVennDiagram(
                        srg1,
                        srg2,
                        out srgOnly_A,
                        out srgOnly_B,
                        out srgOnly_AB);

                    var srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A);
                    var srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B);
                    var srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB);

                    if (createVennToolInputFile)
                    {
                        Console.Error.Write("\nWriting file [{0}]", vennToolInputFileFullPath);
                        var VennOutput = new StreamWriter(vennToolInputFileFullPath);
                        VennOutput.WriteLine("{0} {1} {2}", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases);
                        VennOutput.Close();
                        Console.Error.Write(" ... Done.");
                    }

                    if (createExcelWorkbook)
                    {
                        // create the Excel workbook with a NodeXL Venn diagram
                        Console.Error.Write("\nWriting file [{0}]", excelWorkbookFullPath);
                        var vdd = new VennDiagramData(srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases);
                        try
                        {
                            VennToNodeXL.CreateVennDiagramNodeXLFile(excelWorkbookFullPath, vdd);
                            Console.Error.Write(" ... Done.\n");
                        }
                        catch (Exception e)
                        {
                            Console.Error.Write("Error:  Unable to create Excel workbook.");
                            DisplayException(e);
                            Environment.Exit(-1);
                        }
                    }
                    if (verbose)
                    {
                        Console.Error.Write("\nDump Sequence Groupings from two files\n");
                        SequenceRangeGroupingToString(srgOnly_A, "srgOnly_A");
                        SequenceRangeGroupingToString(srgOnly_B, "srgOnly_B");
                        SequenceRangeGroupingToString(srgOnly_AB, "srgOnly_AB");
                        Console.Error.Write("\nEnd Sequence group from twoe files\n");
                    }

                    Console.Write("\nOutput basepair count for each set");
                    Console.Write("\nGroupA,GroupB,GroupAB");
                    Console.Write("\n{0},{1},{2}\n", srgmOnly_A.bases, srgmOnly_B.bases, srgmOnly_AB.bases);
                }
                else if (arguments.inputFiles.Count() == 3)
                {
                    // TODO:  Reduce memory usage by re-using the SRGs after debugging is complete
                    //
                    // now read the 3 BED files and do the operation to isolate each set
                    SequenceRangeGrouping srg1 = ReadBedFile(arguments.inputFiles[0]);
                    SequenceRangeGrouping srg2 = ReadBedFile(arguments.inputFiles[1]);
                    SequenceRangeGrouping srg3 = ReadBedFile(arguments.inputFiles[2]);

                    SequenceRangeGrouping srgOnly_A,
                                          srgOnly_B,
                                          srgOnly_C,
                                          srgOnly_AB,
                                          srgOnly_AC,
                                          srgOnly_BC,
                                          srgOnly_ABC;

                    VennToNodeXL.CreateSequenceRangeGroupingsForVennDiagram(
                        srg1,
                        srg2,
                        srg3,
                        out srgOnly_A,
                        out srgOnly_B,
                        out srgOnly_C,
                        out srgOnly_AB,
                        out srgOnly_AC,
                        out srgOnly_BC,
                        out srgOnly_ABC);

                    /*
                     * We have the set information data for the three files.  
                     * Now what?
                     */
                    // generate the intersection Venn metrics
                    var srgmOnly_A = new SequenceRangeGroupingMetrics(srgOnly_A);
                    var srgmOnly_B = new SequenceRangeGroupingMetrics(srgOnly_B);
                    var srgmOnly_C = new SequenceRangeGroupingMetrics(srgOnly_C);
                    var srgmOnly_AB = new SequenceRangeGroupingMetrics(srgOnly_AB);
                    var srgmOnly_AC = new SequenceRangeGroupingMetrics(srgOnly_AC);
                    var srgmOnly_BC = new SequenceRangeGroupingMetrics(srgOnly_BC);
                    var srgmOnly_ABC = new SequenceRangeGroupingMetrics(srgOnly_ABC);

                    if (createVennToolInputFile)
                    {
                        Console.Error.Write("\nWriting file [{0}]", vennToolInputFileFullPath);
                        var VennOutput = new StreamWriter(vennToolInputFileFullPath);
                        VennOutput.WriteLine(
                            "{0} {1} {2} {3} {4} {5} {6}",
                            srgmOnly_A.bases,
                            srgmOnly_B.bases,
                            srgmOnly_C.bases,
                            srgmOnly_AB.bases,
                            srgmOnly_AC.bases,
                            srgmOnly_BC.bases,
                            srgmOnly_ABC.bases);
                        VennOutput.Close();
                        Console.Error.Write(" ... Done.");
                    }

                    if (createExcelWorkbook)
                    {
                        // create the NodeXL Venn diagram filefile
                        var vdd = new VennDiagramData(
                            srgmOnly_A.bases,
                            srgmOnly_B.bases,
                            srgmOnly_C.bases,
                            srgmOnly_AB.bases,
                            srgmOnly_AC.bases,
                            srgmOnly_BC.bases,
                            srgmOnly_ABC.bases);
                        // create the Excel workbook with a NodeXL Venn diagram
                        Console.Error.Write("\nWriting file [{0}]", excelWorkbookFullPath);
                        try
                        {
                            VennToNodeXL.CreateVennDiagramNodeXLFile(excelWorkbookFullPath, vdd);
                            Console.Error.Write(" ... Done.\n");
                        }
                        catch (Exception e)
                        {
                            Console.Error.Write("\nError:  Unable to create Excel workbook.");
                            DisplayException(e);
                            Environment.Exit(-1);
                        }
                    }
                    if (verbose)
                    {
                        Console.Error.Write("\nDump Sequence Groupings from three files\n");
                        SequenceRangeGroupingToString(srgOnly_A, "srgOnly_A");
                        SequenceRangeGroupingToString(srgOnly_B, "srgOnly_B");
                        SequenceRangeGroupingToString(srgOnly_C, "srgOnly_C");
                        SequenceRangeGroupingToString(srgOnly_AB, "srgOnly_AB");
                        SequenceRangeGroupingToString(srgOnly_AC, "srgOnly_AC");
                        SequenceRangeGroupingToString(srgOnly_BC, "srgOnly_BC");
                        SequenceRangeGroupingToString(srgOnly_ABC, "srgOnly_ABC");
                        Console.Error.Write("\nEnd Sequence group from three files\n");
                    }

                    Console.Write("\nOutput basepair count for each set");
                    Console.Write("\nGroupA,GroupB,GroupC,GroupAB,GroupAC,GroupBC,GroupABC");
                    Console.Write(
                        "\n{0},{1},{2},{3},{4},{5},{6}\n",
                        srgmOnly_A.bases,
                        srgmOnly_B.bases,
                        srgmOnly_C.bases,
                        srgmOnly_AB.bases,
                        srgmOnly_AC.bases,
                        srgmOnly_BC.bases,
                        srgmOnly_ABC.bases);
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }
            return 0;
        }
Exemple #5
0
 //
 // print 
 public static long SequenceRangeGroupingCBases(SequenceRangeGrouping srg)
 {
     var srgm = new SequenceRangeGroupingMetrics(srg);
     return (srgm.bases);
 }