Commit d48f1622 authored by JinyuanSun's avatar JinyuanSun
Browse files

add an example and update readme

parent 1f0e9ac5
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -134,3 +134,11 @@ test*
ce73fb8a1b802e6746c58ac3bf915d79506e2b5edc36e83f1cbfa3f6071a9a92*
e4f51ecb92f1387f12e6a8f00025990b7c16198bf3643601dc66c55144f0b6f8*
9d58e5ce6d8c9ed839c7cb7d836581dbd48e4ba916403cbd9644f886fd070d2b*
1ff60fa0556049ec1ec285a278566575baf11095f6a7d45162b50415cf998f46*
25eea57f04ad4d86473860fa613061d7544bfa338ef5328253de9c47672c0684*
532130db56afd00f19311341a636a52c7413c013afbb850f0ead705599140c0c*
3387394d26f8fc4bddad1ca2b35bc5a57b8e7f27136bfeb0a2c97764951b273f*
cf08d4763cf8b0309f2aa182c253388d712a1b736d4eb34f226c74588995faa0*
e9bbca7f41ac6c03b3a6c3193115e8ac8a4c4fd572a4230577a81c432b2cacfe*
06377e8a560dca176f9a7d7ac9e3184c6c67e13aa1e9a6a3972e2fde8952375b*
copilot_public/Project-*
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,17 @@ pip install -r requirements.txt
```bash
streamlit run main.py
```

## Example

### Example 1: enzyme for toxin degradation

After the copliot is strateted, change the `Project Name` to `examples/enzyme-for-toxin-degradation`, you will see the history of how copliot:
 - explain the toxin ZEA 
 - find the chemical structure of ZEA
 - search the enzyme for ZEA degradation
 - download predicted 3D structure of the enzyme adn run docking

## Want more funtionality?

You can easily add more functionality to ChatMol copilot. 
+20 −1
Original line number Diff line number Diff line
@@ -345,6 +345,10 @@ class ConversationHandler:
        return response, second_response


# class GLMConversationHandler(ConversationHandler):
#     from zhipuai import ZhipuAI


def compose_chat_completion_message(
    role="assistant", content="", tool_call_dict_list=[]
):
@@ -365,3 +369,18 @@ def compose_chat_completion_message(
        tool_calls=tool_calls,
    )
    return message

def extract_function_and_execute(llm_output, messages):
    name = llm_output.choices[0].message.tool_calls[0].function.name
    params = json.loads(llm_output.choices[0].message.tool_calls[0].function.arguments)
    function_to_call = globals().get(name)
    if not function_to_call:
        raise ValueError(f"Function '{name}' not found")

    messages.append(
        {
            "role": "tool",
            "content": str(function_to_call(**params))
        }
    )
    return messages
 No newline at end of file
+8 −6
Original line number Diff line number Diff line
@@ -271,6 +271,7 @@ class ChatmolFN:
        # # print(log)
        # return res_df.to_string()

    @handle_file_not_found_error
    def call_proteinmpnn_api(
            self,
            path_to_pdb: str,
@@ -308,6 +309,7 @@ class ChatmolFN:
        response = requests.post('https://api.cloudmol.org/protein/proteinmpnn/', params=params, headers=headers, files=files)
        return response.text
    
    @handle_file_not_found_error
    def compare_protein_structures(self, pdb_file1, pdb_file2):
        """
        Compare two protein structures using TMalign
@@ -322,21 +324,21 @@ class ChatmolFN:
    @handle_file_not_found_error
    def protein_single_point_mutation_prediction(self, pdb_file, mutations):
        pythia_res = query_pythia(pdb_file)
        mutation_res = ""
        mutation_res = "Mutation: Energy\n"
        for mutation in pythia_res.split("\n"):
            m, score = mutation.split()
            if m in mutations:
                mutation_res += f"{m} {score}\n"
                mutation_res += f"{m}: {score}\n"
        return mutation_res

    @handle_file_not_found_error
    def recommand_stable_mutations(self, pdb_file, cutoff=-2):
        pythia_res = query_pythia(pdb_file)
        mutation_res = ""
        mutation_res = "Mutation: Energy\n"
        for mutation in pythia_res.split("\n"):
            m, score = mutation.split()
            if float(score) < float(cutoff):
                mutation_res += f"{m} {score}\n"
                mutation_res += f"{m}: {score}\n"
        return mutation_res

    @handle_file_not_found_error
+15.9 KiB

File added.

No diff preview for this file type.

Loading