Skip to content

Commit f3f21e6

Browse files
feat: add from/to spectrum range options to peaks-to-nmrium endpoint
1 parent 324dd83 commit f3f21e6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/routers/spectra.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ class PeaksToNMRiumOptions(BaseModel):
238238
frequency: Optional[float] = Field(400, description="NMR frequency in MHz")
239239
nbPoints: Optional[int] = Field(
240240
131072, description="Number of points for spectrum generation", alias="nb_points")
241-
241+
from_: Optional[float] = Field(
242+
default=None, description="Start of spectrum range", alias="from")
243+
to: Optional[float] = Field(
244+
default=None, description="End of spectrum range", alias="to")
242245
model_config = {"populate_by_name": True}
243246

244247

@@ -608,6 +611,8 @@ async def parse_peaks(request: PeaksToNMRiumRequest):
608611
| `solvent` | string | `""` | NMR solvent |
609612
| `frequency` | float | `400` | NMR frequency in MHz |
610613
| `nb_points` | int | `131072`| Number of spectrum points |
614+
| `from` | int | `undefined` | Start of spectrum range (defaults to first peak value) |
615+
| `to` | int | `undefined` | End of spectrum range (defaults to last peak value) |
611616
612617
### Returns
613618
NMRium-compatible JSON with spectrum data and metadata.
@@ -628,6 +633,10 @@ async def parse_peaks(request: PeaksToNMRiumRequest):
628633
"frequency": request.options.frequency,
629634
"nbPoints": request.options.nbPoints,
630635
}
636+
if request.options.from_ is not None:
637+
payload["options"]["from"] = request.options.from_
638+
if request.options.to is not None:
639+
payload["options"]["to"] = request.options.to
631640

632641
try:
633642
raw_json = run_peaks_to_nmrium_command(payload)

0 commit comments

Comments
 (0)