import pdb
import atom
import sys
from structure import *
from atom import *

def print_dssp():

    empt_line=" " * 145

if(len(sys.argv)<2):
    print("Not enough arguments! Run with --help to learn more about proper"
          "call structure and parameters.")
else:
    pdb_file = pdb.PDBFile(sys.argv[1])
   # print(pdb_file.residues[15].atoms["C"].coord_x)
    #print(pdb_file.residues[2].atoms["N"].res_seq_nb, pdb_file.residues[2].atoms["N"].coord_x, pdb_file.residues[2].atoms["N"].coord_y, pdb_file.residues[2].atoms["N"].coord_z)
    #print(pdb_file.residues[2].atoms["H"].coord_x)
    #print(pdb_file.residues[2].h_bond(pdb_file.residues[40]))
    #print(get_turns(pdb_file.residues))
    #print(pdb_file.residues[27].h_bond(pdb_file.residues[28]))
    #print(get_bridges(pdb_file.residues))


    #turns = get_turns(pdb_file.residues)
    #get_helix(pdb_file.residues, turns)
    #get_bends(pdb_file.residues)
    # get_chirality(pdb_file.residues)
    bridges = get_bridges(pdb_file.residues)
    ladders = get_ladders(bridges, pdb_file.residues)
    get_sheets(ladders)  

    # print("NBRIDGES",len(bridges))

    # bridges = get_bridges(pdb_file.residues)

    # get_bonds(pdb_file.residues)

    residues = pdb_file.residues
    e_min = 0
    for res in residues:
        ene = residues[1].h_bond(res)
        if ene <= e_min:
            e_min = ene
            best_res = res
    #print(residues[1].resid, best_res.resid,e_min)

    #get_phi_psi(residues)
    #print(residues[2].atoms, residues[0].resid, residues[1].resid)
    #print(get_TCO(residues[2],residues[3]))

    for i,res in enumerate(residues):
        # res.get_turns(residues, turns)
        res.get_helix(residues)
        #res.get_bridges(residues)
        #res.get_ladders(residues, ladders)
        #res.get_sheets(residues)

for i,ladder in enumerate(ladders.values()):
    print(chr(65+i))
    
