use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class GavinJob method call.
@Override
public Void call(Progress progress) throws Exception {
progress.setProgressMax(5);
progress.progress(0, "Preprocessing input file...");
Multiset<LineType> lineTypes = parser.tryTransform(inputFile, processedInputFile, errorFile);
progress.status(format("Parsed input file. Found {0} lines ({1} comments, {2} valid VCF, {3} valid CADD, " + "{4} errors, {5} indels without CADD score, {6} skipped)", lineTypes.size(), lineTypes.count(COMMENT), lineTypes.count(VCF), lineTypes.count(CADD), lineTypes.count(ERROR), lineTypes.count(INDEL_NOCADD), lineTypes.count(SKIPPED)));
gavinJobExecution.setLineTypes(lineTypes);
if (lineTypes.contains(SKIPPED)) {
throw new MolgenisDataException(format("Input file contains too many lines. Maximum is {0}.", Parser.MAX_LINES));
}
if (lineTypes.containsAll(Arrays.asList(CADD, VCF))) {
throw new MolgenisDataException("Input file contains mixed line types. Please use one type only, either VCF or CADD.");
}
if (!lineTypes.contains(CADD) && !lineTypes.contains(VCF)) {
throw new MolgenisDataException("Not a single valid variant line found.");
}
File exacInputFile = processedInputFile;
if (!lineTypes.contains(CADD)) {
progress.progress(1, "Annotating with cadd...");
annotatorRunner.runAnnotator(cadd, processedInputFile, caddOutputFile, true);
exacInputFile = caddOutputFile;
} else {
progress.progress(1, "File already annotated by cadd, skipping cadd annotation.");
}
progress.progress(2, "Annotating with exac...");
annotatorRunner.runAnnotator(exac, exacInputFile, exacOutputFile, true);
progress.progress(3, "Annotating with snpEff...");
annotatorRunner.runAnnotator(snpeff, exacOutputFile, snpeffOutputFile, false);
progress.progress(4, "Annotating with gavin...");
annotatorRunner.runAnnotator(gavin, snpeffOutputFile, gavinOutputFile, false);
progress.progress(5, "Result is ready for download.");
String path = menuReaderService.getMenu().findMenuItemPath(GAVIN_APP);
// TODO Filter
// TODO write to database
// TODO result -> GeneNetwork
// TODO VCF pipe aware import
progress.setResultUrl(format("{0}/result/{1}", path, jobIdentifier));
return null;
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class ExcelSheetWriter method add.
/**
* Add a new row to the sheet
*/
@Override
public void add(Entity entity) {
if (entity == null)
throw new IllegalArgumentException("Entity cannot be null");
if (cachedAttributes == null)
throw new MolgenisDataException("The attribute names are not defined, call writeAttributeNames first");
int i = 0;
Row poiRow = sheet.createRow(row++);
for (Attribute attribute : cachedAttributes) {
Cell cell = poiRow.createCell(i++, CellType.STRING);
cell.setCellValue(toValue(entity.get(attribute.getName())));
}
entity.getIdValue();
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class ConnectionRetryConfigTest method testRetryPolicyMolgenisDataException.
@Test
public void testRetryPolicyMolgenisDataException() {
RetryContext context = retryPolicy.open(null);
retryPolicy.registerThrowable(context, new MolgenisDataException("Failed to connect"));
assertTrue(retryPolicy.canRetry(context));
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class CsvIterator method get.
private Entity get() {
if (getNext) {
try {
String[] values = csvReader.readNext();
if (values != null && values.length == colNamesMap.size()) {
List<String> valueList = Arrays.asList(values);
for (int i = 0; i < values.length; ++i) {
// subsequent separators indicate
// null
// values instead of empty strings
String value = values[i].isEmpty() ? null : values[i];
values[i] = processCell(value, false);
}
next = new DynamicEntity(entityType);
for (String name : colNamesMap.keySet()) {
next.set(name, valueList.get(colNamesMap.get(name)));
}
} else if (values != null && (values.length > 1 || (values.length == 1 && values[0].length() > 0)) && values.length < colNamesMap.size()) {
throw new MolgenisDataException(format("Number of values (%d) doesn't match the number of headers (%d): [%s]", values.length, colNamesMap.size(), stream(values).collect(joining(","))));
} else {
next = null;
}
getNext = false;
} catch (IOException e) {
throw new MolgenisDataException(format("Exception reading line of csv file [%s]", repositoryName), e);
}
}
return next;
}
use of org.molgenis.data.MolgenisDataException in project molgenis by molgenis.
the class CsvRepositoryCollection method loadEntityNames.
private void loadEntityNames() {
String extension = StringUtils.getFilenameExtension(file.getName());
entityTypeIds = Lists.newArrayList();
entityTypeIdsLowerCase = Lists.newArrayList();
if (extension.equalsIgnoreCase("zip")) {
ZipFile zipFile = null;
try {
zipFile = new ZipFile(file);
for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); ) {
ZipEntry entry = e.nextElement();
if (!entry.getName().contains(MAC_ZIP) && !entry.isDirectory()) {
String name = getRepositoryName(entry.getName());
entityTypeIds.add(name);
entityTypeIdsLowerCase.add(name.toLowerCase());
}
}
} catch (Exception e) {
throw new MolgenisDataException(e);
} finally {
IOUtils.closeQuietly(zipFile);
}
} else {
String name = getRepositoryName(file.getName());
entityTypeIds.add(name);
entityTypeIdsLowerCase.add(name.toLowerCase());
}
}
Aggregations