Example #1
0
 def test_find_constant_sites_2(self):
     nexus = NexusReader(os.path.join(EXAMPLE_DIR, 'example2.nex'))
     const = find_constant_sites(nexus)
     assert len(const) == 4
     assert 0 in const
     assert 1 in const
     assert 2 in const
     assert 3 in const
Example #2
0
     newnexusname = args[1]
 except IndexError:
     newnexusname = None
     
 
 nexus = NexusReader(nexusname)
 newnexus = None
 
 if options.number:
     if newnexusname is not None:
         print_site_values(nexus, newnexusname)
     else:
         print_site_values(nexus)
         
 elif options.constant:
     const = find_constant_sites(nexus)
     newnexus = new_nexus_without_sites(nexus, const)
     print("Constant Sites: %s" % ",".join([str(i) for i in const]))
 elif options.unique:
     unique = find_unique_sites(nexus)
     newnexus = new_nexus_without_sites(nexus, unique)
     print("Unique Sites: %s" % ",".join([str(i) for i in unique]))
 elif options.stats:
     d = print_character_stats(nexus)
     
 else:
     exit()
     
 # check for saving
 if newnexus is not None and newnexusname is not None:
     newnexus.write_to_file(newnexusname)
Example #3
0
 def test_find_constant_sites_1(self):
     nexus = NexusReader(os.path.join(EXAMPLE_DIR, 'example.nex'))
     assert len(find_constant_sites(nexus)) == 0
    try:
        newnexusname = args[1]
    except IndexError:
        newnexusname = None

    nexus = NexusReader(nexusname)
    newnexus = None

    if options.number:
        if newnexusname is not None:
            print_site_values(nexus, newnexusname)
        else:
            print_site_values(nexus)

    elif options.constant:
        const = find_constant_sites(nexus)
        newnexus = new_nexus_without_sites(nexus, const)
        print("Constant Sites: %s" % ",".join([str(i) for i in const]))
    elif options.unique:
        unique = find_unique_sites(nexus)
        newnexus = new_nexus_without_sites(nexus, unique)
        print("Unique Sites: %s" % ",".join([str(i) for i in unique]))
    elif options.stats:
        d = print_character_stats(nexus)

    else:
        exit()

    # check for saving
    if newnexus is not None and newnexusname is not None:
        newnexus.write_to_file(newnexusname)