def count_chains(structure):
    """
    Uses Biopython to obtain the number of chains.
    Called by: OligoSum.py:main()
    """
    nchains = 0
    for model in structure:
        if model.id == 0:
            for chain in model:
                nres = 0
                nchains += 1
                for residue in chain:
                    nres += 1
    return nchains, nres
