Optimize nupack service startup and compute
This commit is contained in:
commit
e1b3156754
25 changed files with 9435 additions and 0 deletions
64
nupack/app.py
Normal file
64
nupack/app.py
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
from typing import List
|
||||
from nupack import Model, Strand, Tube, SetSpec, tube_analysis
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
class ModelInput(BaseModel):
|
||||
material: str = "rna"
|
||||
ensemble: str = "stacking"
|
||||
celsius: float = 37
|
||||
sodium: float = 1.0
|
||||
magnesium: float = 0.0
|
||||
|
||||
class StrandInput(BaseModel):
|
||||
name: str
|
||||
sequence: str
|
||||
concentration: float
|
||||
unit: str = "uM"
|
||||
|
||||
class TubeInput(BaseModel):
|
||||
name: str = "tube1"
|
||||
max_size: int = 2
|
||||
|
||||
class AnalysisPayload(BaseModel):
|
||||
model: ModelInput
|
||||
strands: List[StrandInput]
|
||||
tube: TubeInput
|
||||
|
||||
def unit_to_molar(value: float, unit: str) -> float:
|
||||
mapping = {"M": 1, "mM": 1e-3, "uM": 1e-6, "nM": 1e-9, "pM": 1e-12}
|
||||
return value * mapping[unit]
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"status": "ok"}
|
||||
|
||||
@app.post("/run")
|
||||
def run(payload: AnalysisPayload):
|
||||
model = Model(
|
||||
material=payload.model.material,
|
||||
ensemble=payload.model.ensemble,
|
||||
celsius=payload.model.celsius,
|
||||
sodium=payload.model.sodium,
|
||||
magnesium=payload.model.magnesium,
|
||||
)
|
||||
|
||||
strands = {}
|
||||
for s in payload.strands:
|
||||
obj = Strand(s.sequence, name=s.name)
|
||||
strands[obj] = unit_to_molar(s.concentration, s.unit)
|
||||
|
||||
tube = Tube(
|
||||
strands=strands,
|
||||
complexes=SetSpec(max_size=payload.tube.max_size),
|
||||
name=payload.tube.name,
|
||||
)
|
||||
|
||||
result = tube_analysis(tubes=[tube], model=model)
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"result": str(result)
|
||||
}
|
||||
8
nupack/requirements.txt
Normal file
8
nupack/requirements.txt
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fastapi
|
||||
uvicorn[standard]
|
||||
numpy
|
||||
scipy
|
||||
pip
|
||||
matplotlib
|
||||
pandas
|
||||
jupyterlab
|
||||
19
nupack/vendor/nupack-4.0.2.0/LICENSE.txt
vendored
Normal file
19
nupack/vendor/nupack-4.0.2.0/LICENSE.txt
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
NUPACK Software License Agreement for Non-Commercial Academic Use
|
||||
|
||||
Copyright (c) 2003–2022. California Institute of Technology. All rights reserved.
|
||||
|
||||
Use of the NUPACK Python module and/or source code (“Software”) in source form and/or binary form, with or without modification, is permitted for non-commercial academic purposes only, subject to the conditions and disclaimer stated below.
|
||||
|
||||
Conditions
|
||||
|
||||
1. Redistribution of the Software in source form and/or binary form is not permitted.
|
||||
2. Web applications that use the Software in source form and/or binary form are not permitted.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote derivative works without specific prior written permission.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Contact
|
||||
|
||||
For any questions about this Software License Agreement please contact info@nupack.org
|
||||
9
nupack/vendor/nupack-4.0.2.0/README.txt
vendored
Normal file
9
nupack/vendor/nupack-4.0.2.0/README.txt
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
README file for NUPACK 4.0
|
||||
Copyright (c) 2003-2022. California Institute of Technology. All Rights Reserved.
|
||||
|
||||
See LICENSE.txt file
|
||||
|
||||
See NUPACK User Guide for installation instructions:
|
||||
https://docs.nupack.org
|
||||
|
||||
Technical support: support@nupack.org
|
||||
19
nupack/vendor/nupack-4.0.2.0/package/LICENSE.txt
vendored
Normal file
19
nupack/vendor/nupack-4.0.2.0/package/LICENSE.txt
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
NUPACK Software License Agreement for Non-Commercial Academic Use
|
||||
|
||||
Copyright (c) 2003–2022. California Institute of Technology. All rights reserved.
|
||||
|
||||
Use of the NUPACK Python module and/or source code (“Software”) in source form and/or binary form, with or without modification, is permitted for non-commercial academic purposes only, subject to the conditions and disclaimer stated below.
|
||||
|
||||
Conditions
|
||||
|
||||
1. Redistribution of the Software in source form and/or binary form is not permitted.
|
||||
2. Web applications that use the Software in source form and/or binary form are not permitted.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote derivative works without specific prior written permission.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Contact
|
||||
|
||||
For any questions about this Software License Agreement please contact info@nupack.org
|
||||
BIN
nupack/vendor/nupack-4.0.2.0/package/nupack-4.0.2.0-cp312-cp312-linux_x86_64.whl
vendored
Normal file
BIN
nupack/vendor/nupack-4.0.2.0/package/nupack-4.0.2.0-cp312-cp312-linux_x86_64.whl
vendored
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue