Accessing values using panda

I am working on getting the dipole energy of the interactions with aminoacids and a macrodipole. I have only used those aminoacids that have ionic tendencies and can have a charge when in water. I have a table where I have the distances between the aminoacid and the macrodipole for each residue, that i use to calculate the potential and then the dipole energy. I believe that in my current code I am not accessing correctly the data, and i don’t know how to do it. Never used panda before and I don’t know if I am stablishing wrong conditions.

The main code is:


def main():

    sequence = input("Enter your sequence: ").strip().upper()
    while True:
        try:
            temperature_kelv = float(input("Enter your temperature in K: "))
            break
        except ValueError:
            print("Invalid input. Please enter a numeric value for temperature.")
             
    # convert kelvin to celsius
    temperature_cels = temperature_kelv - 273.0
    
    # extract segments after obtaining sequence
    segments = extract_segments(sequence)
    
    for segment, n_cap, c_cap in segments:
        print (f"Segment: {segment}, N-cap: {n_cap}, C-cap: {c_cap}")

And this is the dipole function that I am implimenting to get the dipole energy.

    charge_dict = {
    'D': -1,  # Aspartate
    'E': -1,  # Glutamate
    'K': 1,   # Lysine
    'R': 1,   # Arginine
    'H': 1    # Histidine
     }


# Function to calculate dipole energy
def dipole_energy(segment, dipoleN_df, dipoleC_df, charge_dict):
    dipole_energies = []
    for i in range(len(segment)):
        residue = segment[i]
        
        if residue == ['D', 'E', 'K', 'R', 'H']: 
            if i == 1:
                distance_N = dipoleN_df.at[residue, "N-Cap"] 
                distance_C = dipoleC_df.at[residue, "C-Cap"]
            if i == 2:
                distance_N = dipoleN_df.at[residue, "N1"] 
                distance_C = dipoleC_df.at[residue, "C1"]
            if i == 3:
                distance_N = dipoleN_df.at[residue, "N2"] 
                distance_C = dipoleC_df.at[residue, "C2"]
            if i == 4:
                distance_N = dipoleN_df.at[residue, "N3"] 
                distance_C = dipoleC_df.at[residue, "C3"]
            if i == 5:
                distance_N = dipoleN_df.at[residue, "N4"] 
                distance_C = dipoleC_df.at[residue, "C4"]
            if i == 6:
                distance_N = dipoleN_df.at[residue, "N5"] 
                distance_C = dipoleC_df.at[residue, "C5"]
            if i == 7:
                distance_N = dipoleN_df.at[residue, "N6"] 
                distance_C = dipoleC_df.at[residue, "C6"]
            if i == 8:
                distance_N = dipoleN_df.at[residue, "N7"] 
                distance_C = dipoleC_df.at[residue, "C7"]
            if i == 9:
                distance_N = dipoleN_df.at[residue, "N8"] 
                distance_C = dipoleC_df.at[residue, "C8"]
            if i == 10:
                distance_N = dipoleN_df.at[residue, "N9"] 
                distance_C = dipoleC_df.at[residue, "C9"]
            if i == 11:
                distance_N = dipoleN_df.at[residue, "N10"] 
                distance_C = dipoleC_df.at[residue, "C10"]
            if i == 12:
                distance_N = dipoleN_df.at[residue, "N11"] 
                distance_C = dipoleC_df.at[residue, "C11"]
            if i == 13:
                distance_N = dipoleN_df.at[residue, "N12"] 
                distance_C = dipoleC_df.at[residue, "C12"]
            if i == 14:
                distance_N = dipoleN_df.at[residue, "N13"] 
                distance_C = dipoleC_df.at[residue, "C13"]
                
                
            
            # Convert distances from angstroms to meters
            distance_N_m = distance_N * 1e-10
            distance_C_m = distance_C * 1e-10
            
            # Compute the electrostatic potential at the residue 
            potential_N = (1 / (4 * np.pi * epsilon_0)) * (Q * L / distance_N_m**2)
            potential_C = (1 / (4 * np.pi * epsilon_0)) * (Q * L / distance_C_m**2)
            
            # Get the charge of the residue
            charge = charge_dict.get(residue)
            
            # Compute the dipole energy
            dipole_energy = charge * (potential_N + potential_C)
        else:
            dipole_energy = 0.0
        
        dipole_energies.append(dipole_energy)
    
    return dipole_energies

The distance_N and distance_C csv are documents that look like

res N-cap, N1, N2, N3 ...
E.   1.     0.5.  3.8 ....
D .....

and so on.

Can someone help me acces correctly the data?? How am i supposed to do it.

Thank you

New contributor

Eulàlia Canals is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật