use of bio.fkaiser.fit3d.web.model.Fit3DJobParameters in project fit3d by fkaiserbio.
the class SubmitJobView method submit.
public String submit() {
// determine if too many jobs were submitted in current session
int jobCount = getJobCountOfCurrentSession();
if (jobCount > Fit3DWebConstants.JOB_LIMIT) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Too many jobs submitted. Please wait until until some jobs are finished.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
// determine if too many exchanges were defined
if (exchangeDefinitions != null) {
int exchangeCount = (int) exchangeDefinitions.stream().map(ExchangeDefinition::getExchangeAminoAcids).mapToLong(Collection::size).sum();
if (exchangeCount > Fit3DWebConstants.EXCHANGE_LIMIT) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Only " + Fit3DWebConstants.EXCHANGE_LIMIT + " PSEs are allowed. Please use the command line or API version for more complex calculations.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
}
// motif file upload is mandatory
if (!motifFileUploaded) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "A motif file is required.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
}
// use predefined target list if no one was provided
if (!targetListFileUploaded) {
if (predefinedList == PredefinedList.NONE) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Please select or upload a target list.");
FacesContext.getCurrentInstance().addMessage(null, message);
return null;
} else {
targetListPath = predefinedList.getPath();
chainTargetList = true;
}
}
Fit3DJobParameters jobParameters = new Fit3DJobParameters();
jobParameters.setAtomFilterType(atomFilterType);
jobParameters.setChainTargetList(chainTargetList);
jobParameters.setPdbTargetList(pdbTargetList);
if (motifPath.endsWith("4cha_motif.pdb")) {
targetListPath = motifPath.getParent().resolve("targets.txt");
logger.info("example run detected, using short target list {}", targetListPath);
motifPath = motifPath.getParent().resolve("4cha_motif.pdb");
}
jobParameters.setMotifPath(motifPath);
jobParameters.setTargetListPath(targetListPath);
jobParameters.setRmsdLimit(rmsdLimit);
jobParameters.setExchangeDefinitions(exchangeDefinitions);
jobParameters.setStatisticalModelType(statisticalModelType);
Fit3DJob job = new Fit3DJob(jobIdentifier, sessionManager.getSessionIdentifier(), determineIpAddress(), description, email, jobPath, jobParameters);
FacesContext facesContext = FacesContext.getCurrentInstance();
Flash flash = facesContext.getExternalContext().getFlash();
flash.put("job", job);
return "success";
}
use of bio.fkaiser.fit3d.web.model.Fit3DJobParameters in project fit3d by fkaiserbio.
the class JobConverter method toDocument.
public static Document toDocument(Fit3DJob job) {
Fit3DJobParameters parameters = job.getParameters();
List<String> exchangeDefinitionStrings = parameters.getExchangeDefinitions().stream().map(ExchangeDefinition::toString).collect(Collectors.toList());
Document parametersObject = new Document().append("atomFilterType", parameters.getAtomFilterType().toString()).append("pdbTargetList", parameters.isPdbTargetList()).append("chainTargetList", parameters.isChainTargetList()).append("targetListPath", parameters.getTargetListPath().toString()).append("motifPath", parameters.getMotifPath().toString()).append("statisticalModel", parameters.getStatisticalModelType().toString()).append("rmsdLimit", parameters.getRmsdLimit()).append("exchangeDefinitions", exchangeDefinitionStrings);
return new Document().append("timeStamp", job.getTimeStamp().toString()).append("jobIdentifier", job.getJobIdentifier().toString()).append("sessionIdentifier", job.getSessionIdentifier().toString()).append("ipAddress", job.getIpAddress()).append("jobPath", job.getJobPath().toString()).append("description", job.getDescription()).append("email", job.getEmail()).append("enqueued", job.isEnqueued()).append("running", job.isRunning()).append("finished", job.isFinished()).append("failed", job.isFailed()).append("sendMail", job.isSendMail()).append("errorMessage", job.getErrorMessage()).append("parameters", parametersObject);
}
use of bio.fkaiser.fit3d.web.model.Fit3DJobParameters in project fit3d by fkaiserbio.
the class JobConverter method toFit3DJob.
@SuppressWarnings("unchecked")
public static Fit3DJob toFit3DJob(Document jobDocument) {
Document parametersObject = (Document) jobDocument.get("parameters");
List<ExchangeDefinition> exchangeDefinitions = ((List<String>) parametersObject.get("exchangeDefinitions")).stream().map(ExchangeDefinition::fromString).collect(Collectors.toList());
Fit3DJobParameters parameters = new Fit3DJobParameters();
parameters.setAtomFilterType(AtomFilterType.valueOf((String) parametersObject.get("atomFilterType")));
parameters.setPdbTargetList((boolean) parametersObject.get("pdbTargetList"));
parameters.setChainTargetList((boolean) parametersObject.get("chainTargetList"));
parameters.setTargetListPath(Paths.get((String) parametersObject.get("targetListPath")));
parameters.setMotifPath(Paths.get((String) parametersObject.get("motifPath")));
parameters.setStatisticalModelType(StatisticalModelType.valueOf((String) parametersObject.get("statisticalModel")));
parameters.setRmsdLimit((double) parametersObject.get("rmsdLimit"));
parameters.setExchangeDefinitions(exchangeDefinitions);
Fit3DJob fit3dJob = new Fit3DJob();
fit3dJob.setTimeStamp(LocalDateTime.parse((String) jobDocument.get("timeStamp")));
fit3dJob.setSessionIdentifier((UUID.fromString((String) jobDocument.get("sessionIdentifier"))));
fit3dJob.setIpAddress((String) jobDocument.get("ipAddress"));
fit3dJob.setJobIdentifier(UUID.fromString((String) jobDocument.get("jobIdentifier")));
fit3dJob.setJobPath(Paths.get((String) jobDocument.get("jobPath")));
fit3dJob.setDescription((String) jobDocument.get("description"));
fit3dJob.setEmail((String) jobDocument.get("email"));
fit3dJob.setEnqueued((boolean) jobDocument.get("enqueued"));
fit3dJob.setRunning((boolean) jobDocument.get("running"));
fit3dJob.setFinished((boolean) jobDocument.get("finished"));
fit3dJob.setFailed((boolean) jobDocument.get("failed"));
fit3dJob.setSendMail((boolean) jobDocument.get("sendMail"));
fit3dJob.setErrorMessage((String) jobDocument.get("errorMessage"));
fit3dJob.setParameters(parameters);
return fit3dJob;
}
Aggregations