← Pairwise Alignment
Your token

Pairwise Alignment API

The alignment itself, the identity and gap counts, the list of differences and every download run free in the browser and need no API. The API is for the one metered step: send the measurements, the numbered differences, the alignment text and an optional note, and get back, as JSON, a plain-language explanation of what the differences may mean. The page builds this input for you and checks the reply against its own numbers.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "explain".

taskWhat it doesReply
explainReads an alignment's measurements and numbered differences and returns a short summary, notes on the differences that matter (each with an impact: likely_minor, worth_checking, likely_major or unknown), next checks and limits. It never recounts the numbers you send.One JSON object

Input fields

FieldTypeMeaning
taskstring"explain"
kindstring"protein", "dna" or "rna".
modestringHow the pair was aligned: global or local, end gaps, strand, matrix and gap costs.
sequencesstringOne line per sequence: number, name, length, aligned range, FASTA description.
statsstringJSON text: length, identity, identity_pct, similarity, similarity_pct, gaps, gaps_pct, overlap, overlap_identity_pct, coverage_1_pct, coverage_2_pct, score, substitutions, similar_substitutions, insertions, deletions, overhangs, strand.
relationshipstringJSON text {id, label, rule}; id is identical, near_identical, clearly_related, grey_zone, no_clear_relationship or no_overlap.
differencesstringJSON text: a list of {id, type, column, at_1, at_2, ...}, at most 80 (every gap first, then the lowest-scoring substitutions).
alignmentstringThe alignment as 60-column text blocks, at most 6,000 characters (first and last blocks kept, with a marker line).
contextstringOptional note: what the sequences are and what you want to know (at most 2,000 characters).
clipped_notestringEmpty, or sentences saying which part of the input was cut.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence): relationship (the id you sent), summary (2 to 4 sentences), differences (a list of {id, note, impact}, at most 20), next_steps (1 to 4 strings) and caveats (0 to 3 strings). Before showing a note, check its id is one you sent; the page also flags any percentage that is not one of the stats values. If the balance ran low, truncated is true and the object may stop early; the page keeps every note that arrived whole.

Worked example

Input (input.json), from the page's "DNA and its edited copy" example:

{
  "task": "explain",
  "kind": "dna",
  "mode": "global (Needleman-Wunsch), end gaps free, forward strand; scoring NUC.4.4 (EDNAFULL), gap open 10, gap extend 0.5",
  "sequences": "1: original (180 bases, aligned 1-180) - original example sequence\n2: edited (178 bases, aligned 1-178) - edited copy",
  "stats": "{\"length\":181,\"identity\":174,\"identity_pct\":96.1,\"similarity\":174,\"similarity_pct\":96.1,\"gaps\":4,\"gaps_pct\":2.2,\"overlap\":181,\"overlap_identity_pct\":96.1,\"coverage_1_pct\":100,\"coverage_2_pct\":100,\"score\":837,\"substitutions\":3,\"similar_substitutions\":0,\"insertions\":1,\"deletions\":1,\"indels\":2,\"differences\":5,\"overhangs\":0,\"strand\":\"forward\"}",
  "relationship": "{\"id\":\"near_identical\",\"label\":\"Nearly identical\",\"rule\":\"95% or more of the overlapping letters match.\"}",
  "differences": "[{\"id\":\"D1\",\"type\":\"substitution\",\"column\":25,\"at_1\":25,\"at_2\":25,\"letter_1\":\"C\",\"letter_2\":\"G\",\"score\":-4,\"ambiguity_overlap\":false},{\"id\":\"D2\",\"type\":\"substitution\",\"column\":72,\"at_1\":72,\"at_2\":72,\"letter_1\":\"G\",\"letter_2\":\"C\",\"score\":-4,\"ambiguity_overlap\":false},{\"id\":\"D3\",\"type\":\"deletion\",\"column\":101,\"length\":3,\"letters\":\"CCA\",\"present_in\":1,\"at_1\":\"101-103\",\"after_2\":100},{\"id\":\"D4\",\"type\":\"substitution\",\"column\":141,\"at_1\":141,\"at_2\":138,\"letter_1\":\"C\",\"letter_2\":\"G\",\"score\":-4,\"ambiguity_overlap\":false},{\"id\":\"D5\",\"type\":\"insertion\",\"column\":157,\"length\":1,\"letters\":\"T\",\"present_in\":2,\"at_2\":\"154-154\",\"after_1\":156}]",
  "alignment": "original   1 CACGATGTCCTGGGGAAAGTCCTACAGAGTAACAGCGGCAACGAGAGTCACTTGCGCTCT  60\n             |||||||||||||||||||||||| |||||||||||||||||||||||||||||||||||\nedited     1 CACGATGTCCTGGGGAAAGTCCTAGAGAGTAACAGCGGCAACGAGAGTCACTTGCGCTCT  60\n\noriginal  61 GGCTGACTGACGTTCATCTTTGCCTAATAATTAGTAACCTCCAGGTTCAGACTTTGAGGG 120\n             ||||||||||| ||||||||||||||||||||||||||||   |||||||||||||||||\nedited    61 GGCTGACTGACCTTCATCTTTGCCTAATAATTAGTAACCT---GGTTCAGACTTTGAGGG 117\n\noriginal 121 CAGCTCTCCCCCTTACTGGCCTACGCGATTGAGTAG-TTTTATCCCGTTCTCGGACTATA 179\n             |||||||||||||||||||| ||||||||||||||| |||||||||||||||||||||||\nedited   118 CAGCTCTCCCCCTTACTGGCGTACGCGATTGAGTAGTTTTTATCCCGTTCTCGGACTATA 177\n\noriginal 180 C 180\n             |\nedited   178 C 178",
  "context": "This is a stretch of coding sequence from a plasmid, before and after site-directed mutagenesis. Did anything change besides the point mutations I made?",
  "clipped_note": ""
}

Reply:

```json
{
  "relationship": "near_identical",
  "summary": "The original and edited sequences match at 174 of 181 columns (96.1%), with 4 gap columns, which the page reads as nearly identical. The differences are scattered: 3 substitutions plus 2 indels (one deletion and one insertion), and none at the ends. Besides the base changes, the edited copy lost a short stretch of letters and gained a single letter elsewhere, so not everything that changed is a point substitution.",
  "differences": [
    {"id": "D1", "note": "C in sequence 1 became G in sequence 2 at position 25 (score -4): a change between a pyrimidine and a purine (transversion). Check whether this is one of your intended mutations.", "impact": "worth_checking"},
    {"id": "D2", "note": "G in sequence 1 became C in sequence 2 at position 72 (score -4): a transversion. Check whether this is one of your intended mutations.", "impact": "worth_checking"},
    {"id": "D3", "note": "CCA (positions 101-103 of sequence 1) is missing from sequence 2, which carries nothing there: a deletion of length 3 inside the overlap. A length of 3 keeps the reading frame, but removes letters.", "impact": "worth_checking"},
    {"id": "D4", "note": "C at position 141 of sequence 1 became G at position 138 of sequence 2 (score -4): a transversion. Check whether this is one of your intended mutations.", "impact": "worth_checking"},
    {"id": "D5", "note": "A T at position 154 of sequence 2 has nothing opposite it in sequence 1 (after position 156): an insertion of length 1. In coding sequence, a length that is not a multiple of 3 is a frameshift.", "impact": "likely_major"}
  ],
  "next_steps": [
    "Compare D3 and D5 against your mutagenesis design: were a 3-letter deletion and a single-letter insertion planned?",
    "Confirm D3 and D5 in the raw sequencing trace, since indels near repeated letters can be read wrongly.",
    "Check each substitution (D1, D2, D4) against the list of mutations you meant to make."
  ],
  "caveats": [
    "Which changes were intended cannot be told from this alignment; it only shows where the two sequences differ.",
    "A different gap penalty could shift the exact column where a gap sits."
  ]
}
```

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://pairwise-alignment.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"pairwise-alignment"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "explain", "kind": "dna", "mode": "...", "sequences": "...", "stats": "{...}", "relationship": "{...}", "differences": "[...]", "alignment": "...", "context": "", "clipped_note": ""}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="pairwise-alignment:explain:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: relationship, summary, differences, next_steps, caveats
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: pairwise-alignment:explain:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json