INNER CODE UNIT · Python

read_amr_report

StaPH-B/docker-builds · build-files/cbird-util/2.0/plain_report.py:19

def read_amr_report(amr_report):
    df =  pd.read_csv(amr_report, sep = '\t')    
    df2 = df[['Element symbol','Subclass','% Coverage of reference','% Identity to reference', 'Subtype']]
    df2 = df2.rename(columns={'Element symbol':'Gene','Subclass':'AR Subclass/Mechanism','% Coverage of reference':'Coverage(%)','% Identity to reference':'Identity(%)'})
    amr_df = df2.loc[df2['Subtype'] == "AMR"]
    amr_df = amr_df.drop(columns={'Subtype'})
    amr_df = amr_df.sort_values(by=['AR Subclass/Mechanism'], ascending=True)

    point_df = df2.loc[df2['Subtype'] == "POINT"]
    point_df = point_df.drop(columns={'Subtype'})
    point_df = point_df.sort_values(by=['AR Subclass/Mechanism'], ascending=True)

    df_list = [amr_df, point_df]
    return df_list


# Function to add a pandas DataFrame to a docx table
def add_df_to_docx_table(doc, df):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…