Esempio n. 1
0
        public void cytoscape_script_from_topdown()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_community_with_td_proteoforms(-1);

            Sweet.lollipop.target_proteoform_community = community;
            TopDownProteoform td = ConstructorsForTesting.TopDownProteoform("ASDF", 1000, 50);

            td.gene_name = new GeneName(new List <Tuple <string, string> > {
                new Tuple <string, string>("genename", "genename")
            });
            ProteoformFamily fam = new ProteoformFamily(td);

            fam.construct_family();
            CytoscapeScript.write_cytoscape_script(new List <ProteoformFamily>()
            {
                fam
            }, new List <ProteoformFamily>()
            {
                fam
            },
                                                   TestContext.CurrentContext.TestDirectory, "", "test",
                                                   null, false, false,
                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2,
                                                   true, Lollipop.gene_name_labels[1]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(2, shared_pf_names_nodes.Count);
            Assert.AreEqual(2, shared_pf_names_edges.Count);
        }
Esempio n. 2
0
        public void cytoscape_edges_and_nodes_match()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            Sweet.lollipop.target_proteoform_community = community;
            IEnumerable <TheoreticalProteoform> theoreticals = community.families.SelectMany(f => f.theoretical_proteoforms);
            string edges = CytoscapeScript.get_cytoscape_edges_tsv(community.families,
                                                                   Lollipop.edge_labels[0], Lollipop.node_labels[0], 2,
                                                                   theoreticals, false, Lollipop.gene_name_labels[1]);

            string[]         lines = edges.Split(new char[] { '\n' });
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    break;
                }
                string[] line = lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string nodes = CytoscapeScript.get_cytoscape_nodes_tsv(community.families, null,
                                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], Lollipop.node_positioning[0], 2,
                                                                   theoreticals, false, Lollipop.gene_name_labels[1]);

            lines = nodes.Split(new char[] { '\n' });
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    break;
                }
                string[] line = lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(9, shared_pf_names_nodes.Count); //both families
        }
Esempio n. 3
0
        public void cytoscape_script_from_subset_of_families()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            Sweet.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(new List <ProteoformFamily> {
                community.families[0]
            }, community.families,
                                                   TestContext.CurrentContext.TestDirectory, "", "test",
                                                   null, false, false,
                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2,
                                                   false, Lollipop.gene_name_labels[1]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(community.families.First().proteoforms.Count, shared_pf_names_nodes.Count);
        }
        public void cytoscape_script_from_theoreticals()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.gene_centric_families = false;
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals(false);

            Sweet.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(community.families.SelectMany(f => f.theoretical_proteoforms.Where(t => t.ExpandedProteinList.Select(p => p.FullName).Contains(TestProteoformFamilies.p1_fullName))).ToArray(), community.families,
                                                   TestContext.CurrentContext.TestDirectory, "", "test",
                                                   null, false, false,
                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2,
                                                   false, Lollipop.gene_name_labels[1]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(5, shared_pf_names_nodes.Count); //only the first family
        }
        public void cytoscape_script_from_gotermnumber()
        {
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            SaveState.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(new GoTermNumber[] { new GoTermNumber(TestProteoformFamilies.p1_goterm, 0, 0, 0, 0) }, community.families,
                                                   TestContext.CurrentContext.TestDirectory, "", "test",
                                                   false, false, false,
                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2,
                                                   false, Lollipop.gene_name_labels[1]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(9, shared_pf_names_nodes.Count); //both families this time because they all have the same stuff...
        }