From 830fa2f83c8a3ace5a614d52689bd2fb621fa000 Mon Sep 17 00:00:00 2001 From: Jonas Almeida Date: Tue, 14 Nov 2023 11:06:55 -0500 Subject: [PATCH] GC content calculation --- export.js | 5 ++++- functions/testFunctions.mjs | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/export.js b/export.js index 050efe4..3f404c0 100644 --- a/export.js +++ b/export.js @@ -194,7 +194,7 @@ async function chatUI(div){ // cerate a simple chat div let selectRole=document.createElement('select') selectRole.id = "selectRole" div.appendChild(selectRole); - ['system','user','assistant'].forEach(r=>{ + ['system','user','assistant','function'].forEach(r=>{ let opt = document.createElement('option') selectRole.appendChild(opt) opt.value=r @@ -329,6 +329,9 @@ async function chatUI(div){ // cerate a simple chat div if(x.choices[0].finish_reason=="function_call"){ console.log(`function_call:`,x) let msg=x.choices[0].message + msg.role="function" + msg.name=msg.function_call.name + delete msg.function_call msgs.push(msg) // show result in the UI // continue back to the loop diff --git a/functions/testFunctions.mjs b/functions/testFunctions.mjs index b2fabe8..d733132 100644 --- a/functions/testFunctions.mjs +++ b/functions/testFunctions.mjs @@ -77,6 +77,30 @@ const fetchUCSC = { // at NCI Shady Grove } }; +function funGCcontent(parms){ + parms = parms||{ + sequence:'AGAAGGAAAACGGGAAACTTCACAATTAGTGAATATTTAAAAACAGACTCTTAAGAAACCAAAGGATCAAGGAAGATACCACAGGGAAAAATAGAGAATA' + } + // calculate GC funGCcontent + let GClength = parms.sequence.toUpperCase().split('').filter(x=>(x=='G'|x=='C')).length + let seqLength = parms.sequence.length + return `GC content is ${GClength}/${seqLength} = ${GClength/seqLength}` +} + +const defGCcontent={ + "name": "funGCcontent", + "description": "calculate the GC content of a DNA sequence", + "parameters": { + "type":"object", + "properties":{ + "sequence":{ + "type":"string", + "description":"a DNA or genomic sequence, composed with four letters: A, C, G, and T" + } + } + } +} + async function rankSumTest(parms){ // lets do t-test to warm things up parms=parms||{ @@ -124,5 +148,7 @@ export{ fetchUCSC, funFetchUCSC, rankSumTest, - rankSumTestDescription + rankSumTestDescription, + funGCcontent, + defGCcontent } \ No newline at end of file