示例#1
0
    def testEasyAssembly(self):

        reads = ["Hello", "o_my_friend", "d_its_me"]
        nodes = [Node(str) for str in reads]
        graph = Graph(nodes)
        assembled = graph.assemble()

        self.assertEqual(assembled, "Hello_my_friend_its_me")
示例#2
0
    def testPaths(self):

        nodes = [ Node(read) for read in ["AAA", "AGG", "GTT", "TCA"]]
        graph = Graph(nodes)

        edge = Edge(1, nodes[0], nodes[1])
        
        self.assertFalse(graph.will_create_cycle(edge))
        nodes[0].out_edges.append(edge)
        nodes[1].in_edges.append(edge)

        other_edge = Edge(0, nodes[1], nodes[0])

        self.assertTrue(graph.will_create_cycle(other_edge))
示例#3
0
    def testSampleAssembly(self):

        read_file = "test/test.reads"

        nodes = []
        with open(read_file) as fh:
            for line in fh:
                nodes.append(Node(line.rstrip()))
        
        graph = Graph(nodes)
        assembled = graph.assemble()
        answer = "the_quick_brown_fox_jumps_over_the_lazy_dog"
        
        self.assertEqual(assembled, answer)
示例#4
0
def main():
    parser = argparse.ArgumentParser(
        description = (" An implemention of a greedy sequence assembler using Graphs / Ham Paths"),
    )

    parser.add_argument("--reads")
    parser.add_argument("--fastq", help="Option to process reads as a fastq file")
    opts = parser.parse_args()
    
    log.info("Starting Greedy Assembly")
    log.info("Read file: %s", opts.reads)

    if opts.reads:
        nodes = read_file_to_node_set(opts.reads)
        graph = Graph(nodes)
        print(graph.assemble())

    elif opts.fastq:
        nodes = fastq_file_to_node_set(opts.fastq)
        graph = Graph.Graph(nodes)
        print(graph.assemble())
示例#5
0
    def testWillCycle(self):
        reads = ["AAA", "AGG", "GTT"]
        
        first_node = Node("AAA")
        second_node = Node("AGG")
        third_node = Node("GGT")

        graph = Graph([first_node, second_node, third_node])

        # add edges
        fs_edge = Edge(0, first_node, second_node)
        first_node.out_edges.append(fs_edge)
        second_node.in_edges.append(fs_edge)

        st_edge = Edge(0, second_node, third_node)
        second_node.out_edges.append(st_edge)
        third_node.in_edges.append(st_edge)

        # cycle edge
        tf_edge = Edge(0, third_node, first_node)
        self.assertTrue(graph.will_create_cycle(tf_edge))