Search in sources :

Example 1 with ExportFactoryMarshaller

use of eu.isas.peptideshaker.utils.ExportFactoryMarshaller in project peptide-shaker by compomics.

the class PSExportFactory method saveFactory.

/**
 * Saves the factory in the user folder.
 *
 * @param psExportFactory the instance of the factory to save
 *
 * @throws IOException exception thrown whenever an error occurred while
 * saving the PSExportFactory
 */
public static void saveFactory(PSExportFactory psExportFactory) throws IOException {
    File factoryFile = new File(JSON_FILE);
    if (!factoryFile.getParentFile().exists()) {
        factoryFile.getParentFile().mkdir();
    }
    JsonMarshaller jsonMarshaller = new ExportFactoryMarshaller();
    jsonMarshaller.saveObjectToJson(psExportFactory, factoryFile);
}
Also used : ExportFactoryMarshaller(eu.isas.peptideshaker.utils.ExportFactoryMarshaller) File(java.io.File) JsonMarshaller(com.compomics.util.io.json.JsonMarshaller)

Example 2 with ExportFactoryMarshaller

use of eu.isas.peptideshaker.utils.ExportFactoryMarshaller in project peptide-shaker by compomics.

the class PSExportFactory method loadFromFile.

/**
 * Loads an export factory from a file. The file must be an export of the
 * factory in the json format.
 *
 * @param file the file to load
 *
 * @return the export factory saved in file
 *
 * @throws IOException exception thrown whenever an error occurred while
 * loading the file
 */
public static PSExportFactory loadFromFile(File file) throws IOException {
    JsonMarshaller jsonMarshaller = new ExportFactoryMarshaller();
    PSExportFactory result = (PSExportFactory) jsonMarshaller.fromJson(PSExportFactory.class, file);
    return result;
}
Also used : ExportFactoryMarshaller(eu.isas.peptideshaker.utils.ExportFactoryMarshaller) JsonMarshaller(com.compomics.util.io.json.JsonMarshaller)

Aggregations

JsonMarshaller (com.compomics.util.io.json.JsonMarshaller)2 ExportFactoryMarshaller (eu.isas.peptideshaker.utils.ExportFactoryMarshaller)2 File (java.io.File)1