Skip to content

Commit

Permalink
Best design renders (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
acashmoney committed May 2, 2024
1 parent 368eca1 commit c7f8090
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
15 changes: 14 additions & 1 deletion gateway/utils/web3.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ func BuildTokenMetadata(db *gorm.DB, flow *models.Flow) (string, error) {
metadata := map[string]interface{}{
"name": flow.Name,
"description": "Research, Reimagined. All Scientists Welcome.",
"image": "ipfs://QmQZLrUPxh4WMmzpQGhUYRsMwU2BXfmFa3YAFhFKkRgHTZ", // Default image is glitchy LabDAO logo gif
"image": "",
"flow": []map[string]interface{}{},
}

var pngCID string

for _, job := range jobs {
var tool models.Tool
if err := db.Where("cid = ?", job.ToolID).First(&tool).Error; err != nil {
Expand Down Expand Up @@ -150,9 +152,20 @@ func BuildTokenMetadata(db *gorm.DB, flow *models.Flow) (string, error) {
"cid": outputPinataHash,
"filename": outputFile.Filename,
})

if filepath.Ext(outputFile.Filename) == ".png" && pngCID == "" {
pngCID = outputPinataHash
}
}
}

if pngCID != "" {
metadata["image"] = "ipfs://" + pngCID
} else {
// Default image is glitchy LabDAO logo gif
metadata["image"] = "ipfs://QmQZLrUPxh4WMmzpQGhUYRsMwU2BXfmFa3YAFhFKkRgHTZ"
}

metadata["flow"] = append(metadata["flow"].([]map[string]interface{}), ioObject)
}

Expand Down
4 changes: 2 additions & 2 deletions tools/colabdesign/colabdesign.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "colabdesign v1.7",
"name": "colabdesign v1.8",
"description": "RFdiffusion is a method for structure generation, with or without conditional information (a motif, target etc). It can perform a whole range of protein design challenges. This version includes creating checkpoints for this model",
"guide": "Note: steps marked (optional) and (advanced) give additional constraints for the designs but it is not necessary to add/edit their input in order to submit an experimental run.\n\n1. Select a .pdb file containing the *target protein* you would like to design a binder against.\n2. (optional) Select a *target chain* from the pdb file (chain A is the default). \n3. (optional) Crop the target structure by specifying the *target start residue* and the *target end residue* on the target chain. \n4. (optional) Define *hotspot* residues on the target as the binding sites, stating the chain (e.g. A) followed by the number of the residue (e.g. A30). You can specify multiple hotspots at once.\n5. Specify the *binder length* (total number of residues) you wish to design, followed by the *number of binders* to design (max 8 per run). \n6. (advanced) Define a *contigs override* that constrains the binder design to a subset of the residues. The contig consists of information on the target and the binder, separated by a colon. Residues which are to be kept fixed, are indicated by the chain label followed by the range of residue numbers. A number without a chain label indicates the number of residues to be designed.", "author": "sokrypton",
"github": "https://github.com/sokrypton/ColabDesign",
Expand All @@ -12,7 +12,7 @@
],
"arguments": [
],
"dockerPull": "quay.io/labdao/colabdesign@sha256:9c149aedc355f7b1ef733f984d1966699be9ec9df2e8b758fd3a035303f078f8",
"dockerPull": "quay.io/labdao/colabdesign@sha256:cdff5c0870c6cf67f2d3501c5318be9e56c6fab25d714b22259e29934302bb98",
"gpuBool": true,
"memoryGB": 12,
"cpu": 3,
Expand Down
26 changes: 15 additions & 11 deletions tools/colabdesign/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def create_and_upload_checkpoints(df_results, result_csv_path, flow_uuid, job_uu
best_per_design.reset_index(inplace=True)

for index, row in best_per_design.iterrows():
plddt_for_checkpoint = row['plddt'] *100
plddt_for_checkpoint = row['plddt'] * 100
i_pae_for_checkpoint = row['i_pae']
design = row['design']
n = row['n']
Expand All @@ -124,23 +124,27 @@ def create_and_upload_checkpoints(df_results, result_csv_path, flow_uuid, job_uu
}, index=[0])
event_csv_filename = f"checkpoint_{index}_summary.csv"
event_csv_filepath = f"{checkpoint_csv_path}/{event_csv_filename}"
new_df.to_csv(event_csv_filepath, index= False)
new_df.to_csv(event_csv_filepath, index=False)

bucket_name = "app-checkpoint-bucket"
object_name = f"checkpoints/{flow_uuid}/{job_uuid}/checkpoint_{index}"
upload_to_s3(event_csv_filepath, bucket_name, f"{object_name}/{event_csv_filename}")
upload_to_s3(pdb_path, bucket_name, f"{object_name}/{pdb_file_name}")
print(f"Checkpoint {index} event CSV and PDB created and uploaded.")

print("visualising the protein complex")
result = visualise_protein_complex(pdb_path, result_csv_path)
png_file_path = result.get('png')
png_file_name = os.path.basename(png_file_path)
bucket_name = "app-record-bucket"
object_name = f"visualizations/{flow_uuid}/{job_uuid}"
upload_to_s3(png_file_path, bucket_name, f"{object_name}/{png_file_name}")
os.remove(event_csv_filepath)
print(f"Visualizations uploaded to S3.")
overall_best_design = df_sorted.iloc[0]
overall_best_design_pdb_file_name = f"design{overall_best_design['design']}_n{overall_best_design['n']}.pdb"
overall_best_design_pdb_path = f"{checkpoint_csv_path}/default/all_pdb/{overall_best_design_pdb_file_name}"

print("Visualizing the protein complex for the overall best design")
result = visualise_protein_complex(overall_best_design_pdb_path, result_csv_path)
png_file_path = result.get('png')
png_file_name = os.path.basename(png_file_path)
bucket_name = "app-record-bucket"
object_name = f"visualizations/{flow_uuid}/{job_uuid}"
upload_to_s3(png_file_path, bucket_name, f"{object_name}/{png_file_name}")
os.remove(event_csv_filepath)
print(f"Visualization for the overall best design uploaded to S3.")
return

def enricher(multirun_path, cfg, flow_uuid, job_uuid, checkpoint_compatible):
Expand Down

0 comments on commit c7f8090

Please sign in to comment.