Visualizing COVID-19: Integrating the Symbia COVID-20figs Cognitive Actions
The Symbia COVID-20figs Cognitive Actions offer developers powerful tools for generating detailed visual representations of the SARS-CoV-2 virus structure, particularly its spike protein. By leveraging these pre-built actions, you can create informative and visually striking images that enhance your applications, whether for educational purposes, research, or public awareness campaigns.
Prerequisites
Before you start using the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic understanding of JSON and how to make API calls.
For authentication, you'll typically include your API key in the request headers. This allows you to securely access the Cognitive Actions and execute their functionalities.
Cognitive Actions Overview
Generate Image with COVID-19 Structure Visualization
This action generates a detailed visual representation of the SARS-CoV-2 spike protein trimer in its prefusion state, showcasing distinctive structural features and colored protomers.
Input
The input for this action requires several fields, with the prompt being mandatory. Here's the schema for the input:
{
"prompt": "string",
"model": "string",
"guidanceScale": "number",
"mainLoraScale": "number",
"promptStrength": "number",
"numberOfOutputs": "integer",
"imageAspectRatio": "string",
"imageOutputFormat": "string",
"imageOutputQuality": "integer",
"inferenceStepCount": "integer",
"additionalLoraScale": "number"
}
Example Input:
{
"model": "dev",
"prompt": "covidfig of SARS-CoV-2 spike protein trimer in its prefusion state. 3 distinct protomers forming a mushroom-like structure, each protomer highlighted in a different color: one in light blue, one in light green, one in light purple. The spike protein consists of an S1 subunit (larger top portion) and an S2 subunit (lower stem portion). S1 subunits include receptor-binding domains (RBDs), one in 'up' conformation colored in bright yellow to indicate an active binding state, two in 'down' conformation in light blue and purple respectively. Glycans depicted as green tree-like structures distributed along the surface of each protomer. S2 subunit forming the elongated stalk is represented with a textured cylindrical structure to emphasize heptad repeats and fusion peptide regions. Membrane-proximal region (MPR) shown in dark grey near the base, indicating proximity to the viral envelope. Overall, structure sits atop a semi-transparent grey circle representing the viral membrane. Labels for RBD, NTD (N-terminal domain in the S1 subunit), HR1/HR2 (heptad repeat regions), and fusion peptide included for clarity.",
"guidanceScale": 3.5,
"mainLoraScale": 1,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"inferenceStepCount": 28,
"additionalLoraScale": 1
}
Output
The action typically returns a URL pointing to the generated image. Here’s an example of the output you might receive:
[
"https://assets.cognitiveactions.com/invocations/178f1342-4768-43bb-8497-b5280913f6c9/041e834f-743b-4245-bf7c-4381fef6dfd2.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call this action using Python:
import requests
import json
# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint
action_id = "8da12ccd-1037-4f9b-9661-5f967a43bb37" # Action ID for Generate Image with COVID-19 Structure Visualization
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "covidfig of SARS-CoV-2 spike protein trimer in its prefusion state. 3 distinct protomers forming a mushroom-like structure, each protomer highlighted in a different color: one in light blue, one in light green, one in light purple. The spike protein consists of an S1 subunit (larger top portion) and an S2 subunit (lower stem portion). S1 subunits include receptor-binding domains (RBDs), one in 'up' conformation colored in bright yellow to indicate an active binding state, two in 'down' conformation in light blue and purple respectively. Glycans depicted as green tree-like structures distributed along the surface of each protomer. S2 subunit forming the elongated stalk is represented with a textured cylindrical structure to emphasize heptad repeats and fusion peptide regions. Membrane-proximal region (MPR) shown in dark grey near the base, indicating proximity to the viral envelope. Overall, structure sits atop a semi-transparent grey circle representing the viral membrane. Labels for RBD, NTD (N-terminal domain in the S1 subunit), HR1/HR2 (heptad repeat regions), and fusion peptide included for clarity.",
"guidanceScale": 3.5,
"mainLoraScale": 1,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"inferenceStepCount": 28,
"additionalLoraScale": 1
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json"
}
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json={"action_id": action_id, "inputs": payload} # Hypothetical structure
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body: {e.response.text}")
In this example, the payload is constructed according to the action's input requirements. The API endpoint and action ID are illustrative, and you should replace them with the actual values specific to your implementation.
Conclusion
The Symbia COVID-20figs Cognitive Actions provide an innovative way to visualize complex biological structures, making it easier for developers to integrate scientific imagery into their applications. By using these actions, you can create engaging content that enhances understanding of COVID-19 and its implications. Consider exploring additional use cases, such as educational platforms, research presentations, or public health awareness campaigns, to leverage the full potential of these tools.