Пример #1
0
def test_error_on_too_many_states():
    nex = NexusReader.from_string("""
    Begin data;
    Dimensions ntax=1 nchar=30;
    Format datatype=standard symbols="01" gap=-;
    Matrix
    A   111111111111111111111111111111
    ;""")
    with pytest.raises(ValueError):
        multistatise(nex)
Пример #2
0
 def test_error_on_too_many_states(self):
     self.nex = NexusReader()
     self.nex.read_string("""
     Begin data;
     Dimensions ntax=1 nchar=30;
     Format datatype=standard symbols="01" gap=-;
     Matrix
     A   111111111111111111111111111111
     ;""")
     with self.assertRaises(ValueError):
         multistatise(self.nex)
Пример #3
0
def nex():
    res = NexusReader.from_string("""
        Begin data;
        Dimensions ntax=4 nchar=4;
        Format datatype=standard symbols="01" gap=-;
        Matrix
        Harry              1000
        Simon              0100
        Betty              0010
        Louise             0001
        ;""")
    return multistatise(res)
Пример #4
0
 def setUp(self):
     self.nex = NexusReader()
     self.nex.read_string("""
     Begin data;
     Dimensions ntax=4 nchar=4;
     Format datatype=standard symbols="01" gap=-;
     Matrix
     Harry              1000
     Simon              0100
     Betty              0010
     Louise             0001
     ;""")
     self.nex = multistatise(self.nex)
 def setUp(self):
     self.nex = NexusReader()
     self.nex.read_string("""
     Begin data;
     Dimensions ntax=4 nchar=4;
     Format datatype=standard symbols="01" gap=-;
     Matrix
     Harry              1000
     Simon              0100
     Betty              0010
     Louise             0001
     ;""")
     self.nex = multistatise(self.nex)
Пример #6
0
    def test_regression_include_invisible_taxa(self):
        """Include taxa that have no entries"""
        data = """
        #NEXUS
        
        BEGIN DATA;
            DIMENSIONS  NTAX=15 NCHAR=7;
            FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=YES;
        MATRIX
        
        Gertrude                0000001
        Debbie                  0001000
        Zarathrustra            0000000
        Christie                0010000
        Benny                   0100000
        Bertha                  0100000
        Craig                   0010000
        Fannie-May              0000010
        Charles                 0010000
        Annik                   1000000
        Frank                   0000010
        Amber                   1000000
        Andreea                 1000000
        Edward                  0000100
        Donald                  0001000
        ;
        END;
        """

        nex = NexusReader()
        nex.read_string(data)
        msnex = multistatise(nex)

        for taxon, sites in msnex.data.matrix.items():
            if taxon[0] == 'Z':
                continue  # will check later

            # first letter of taxa name is the expected character state
            assert taxon[0] == sites[0], \
                "%s should be %s not %s" % (taxon, taxon[0], sites[0])
        # deal with completely missing taxa
        assert 'Zarathrustra' in msnex.data.matrix
        assert msnex.data.matrix['Zarathrustra'][0] == '?'
 def test_regression_include_invisible_taxa(self):
     """Include taxa that have no entries"""
     data = """
     #NEXUS
     
     BEGIN DATA;
         DIMENSIONS  NTAX=15 NCHAR=7;
         FORMAT DATATYPE=STANDARD MISSING=? GAP=- INTERLEAVE=YES;
     MATRIX
     
     Gertrude                0000001
     Debbie                  0001000
     Zarathrustra            0000000
     Christie                0010000
     Benny                   0100000
     Bertha                  0100000
     Craig                   0010000
     Fannie-May              0000010
     Charles                 0010000
     Annik                   1000000
     Frank                   0000010
     Amber                   1000000
     Andreea                 1000000
     Edward                  0000100
     Donald                  0001000
     ;
     END;
     """
     
     nex = NexusReader()
     nex.read_string(data)
     msnex = multistatise(nex)
     
     for taxon, sites in msnex.data.matrix.items():
         if taxon[0] == 'Z':
             continue  # will check later
         
         # first letter of taxa name is the expected character state
         assert taxon[0] == sites[0], \
             "%s should be %s not %s" % (taxon, taxon[0], sites[0])
     # deal with completely missing taxa
     assert 'Zarathrustra' in msnex.data.matrix
     assert msnex.data.matrix['Zarathrustra'][0] == '?'
Пример #8
0
        usage="usage: %prog [-o output.nex] nex1.nex nex2.nex ... nexN.nex")
    parser.add_option("-o",
                      "--output",
                      dest="output",
                      action="store",
                      default=None,
                      type="string",
                      help="output nexus file")
    options, nexuslist = parser.parse_args()

    if len(nexuslist) < 1:
        print(__doc__)
        parser.print_help()
        sys.exit()

    if options.output is not None:
        outfile = options.output
    else:
        outfile = 'multistate.nex'

    nexuslist2 = []
    for nfile in nexuslist:
        n = NexusReader(nfile)
        n = multistatise.multistatise(n)
        nexuslist2.append(n)

    out = combine_nexuses(nexuslist2)

    out.write_to_file(outfile, charblock=True, interleave=False)
    print("Written to %s" % outfile)
Пример #9
0
def run(args):
    nexuslist = [
        multistatise.multistatise(n) for n in get_reader(args, many=True)
    ]
    write_output(combine_nexuses(nexuslist), args)