import React, { Component } from 'react'; // Component for the advanced params input field. export class Options extends Component { constructor(props) { super(props); this.state = { textValue: '', objectValue: this.defaultObjectValue(), paramsMode: 'advanced' }; this.onTextValueChanged = this.onTextValueChanged.bind(this); this.optionsPresetsJSX = this.optionsPresetsJSX.bind(this); this.advancedParamsJSX = this.advancedParamsJSX.bind(this); this.showAdvancedOptionsHelp = this.showAdvancedOptionsHelp.bind(this); } defaultObjectValue() { return { max_target_seqs: '', evalue: '', task: '' }; }; componentDidUpdate(prevProps) { if (prevProps.predefinedOptions !== this.props.predefinedOptions) { let defaultOptions = this.props.predefinedOptions.default || {attributes: []}; let advancedOptions = this.props.predefinedOptions['last search'] || defaultOptions || {attributes: []}; let initialTextValue = advancedOptions.attributes.join(' ').trim(); let parsedOptions = this.parsedOptions(initialTextValue); this.setState({ textValue: initialTextValue, objectValue: parsedOptions}); } } onTextValueChanged(textValue) { let parsedOptions = this.parsedOptions(textValue.toString()); this.setState({ textValue: textValue.toString(), objectValue: parsedOptions }); } parsedOptions(textValue) { const words = textValue.split(" "); let parsedOptions = this.defaultObjectValue(); // Iterate through the words in steps of 2, treating each pair as an option and its potential value for (let i = 0; i < words.length; i += 2) { // Ensure there is a pair available if (words[i]) { if (words[i].startsWith("-")) { const optionName = words[i].substring(1).trim(); if (words[i + 1]) { // Use the second word as the value for this option parsedOptions[optionName] = words[i + 1]; } else { // No value found for this option, set it to null or a default value parsedOptions[optionName] = null; } } } } return parsedOptions; } optionsPresetsJSX() { return (
Choose a predefined setting or customize BLAST parameters.
{this.presetListJSX()} >}