Here are the examples of the java api lib.export.ExportWriter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
17
Source : AptaPlexProducer.java
with GNU General Public License v3.0
from drivenbyentropy
with GNU General Public License v3.0
from drivenbyentropy
@Override
public void run() {
// the files we need to process
String[] forward_files = Configuration.getParameters().getStringArray("AptaplexParser.forwardFiles");
String[] reverse_files = Configuration.getParameters().getStringArray("AptaplexParser.reverseFiles");
// Sanity checks
// make sure the forward read files exist
if (forward_files.length == 0) {
throw new InvalidSequenceReadFileException("No forward read files where specified. Please check your configuration.");
}
// if they exist, we need the same number of forward and reverse files, or no reverse files in
// case of single end sequencing
if (reverse_files.length != 0 && forward_files.length != reverse_files.length) {
throw new InvalidSequenceReadFileException("The number of forward and reverse read files must be identical.");
}
// iterate over all files and populate the queue
for (int x = 0; x < forward_files.length; x++) {
Path current_forward_file_path = Paths.get(forward_files[x]);
Path current_reverse_file_path = null;
// at this point we know reverse_files.length is either 0 or equal to forward_file.length
if (reverse_files.length != 0) {
current_reverse_file_path = Paths.get(reverse_files[x]);
}
// Create a new Reader instance. Use reflection so we can define the backend in the configuration
Reader reader = null;
Clreplaced reader_clreplaced = null;
try {
reader_clreplaced = Clreplaced.forName("lib.parser.aptaplex." + Configuration.getParameters().getString("AptaplexParser.reader"));
} catch (ClreplacedNotFoundException e) {
AptaLogger.log(Level.SEVERE, this.getClreplaced(), "Error, the backend for the Reader could not be found.");
AptaLogger.log(Level.SEVERE, this.getClreplaced(), org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e));
e.printStackTrace();
System.exit(0);
}
// Try to instantiate the clreplaced
boolean instanceSuccess = false;
try {
reader = (Reader) reader_clreplaced.getConstructor(Path.clreplaced, Path.clreplaced).newInstance(current_forward_file_path, current_reverse_file_path);
instanceSuccess = true;
} catch (InstantiationException e) {
AptaLogger.log(Level.SEVERE, this.getClreplaced(), "Error, could not instantiate the backend for the AptaplexParser.reader");
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
AptaLogger.log(Level.SEVERE, this.getClreplaced(), "Error invoking construtor of AptaplexParser.reader backend");
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} finally {
if (!instanceSuccess) {
AptaLogger.log(Level.SEVERE, this.getClreplaced(), "Error invoking AptaplexParser.reader backend");
System.exit(0);
}
}
// at this point we can fill the undetermined map if requested by the user
if (this.undeterminedExportWriterMap != null) {
// first create the export writers
Path forward_export_path = Paths.get(exportPath.toString(), "undetermined_" + current_forward_file_path.getFileName().toString() + (Configuration.getParameters().getBoolean("Export.compress") ? ".gz" : ""));
ExportWriter forward_export_writer = Configuration.getParameters().getBoolean("Export.compress") ? new CompressedExportWriter() : new UncompressedExportWriter();
forward_export_writer.open(forward_export_path);
Path reverse_export_path = null;
if (current_reverse_file_path != null) {
reverse_export_path = Paths.get(exportPath.toString(), "undetermined_" + current_reverse_file_path.getFileName().toString() + (Configuration.getParameters().getBoolean("Export.compress") ? ".gz" : ""));
ExportWriter reverse_export_writer = Configuration.getParameters().getBoolean("Export.compress") ? new CompressedExportWriter() : new UncompressedExportWriter();
reverse_export_writer.open(reverse_export_path);
}
undeterminedExportWriterMap.put(current_forward_file_path, new Pair(forward_export_writer, reverse_export_path));
}
try {
// get the first read
Read read = reader.getNextRead();
// do the same for the remaining reads
while (read != null) {
// are we multiplexing?
if (isPerFile) {
// add cycle information to read
read.selection_cycle = Configuration.getExperiment().getAllSelectionCycles().get(x);
}
// add source files
read.source_forward = current_forward_file_path;
read.source_reverse = current_reverse_file_path;
// put read into to queue
queue.put(read);
totalProcessedReads++;
// get the next read
read = reader.getNextRead();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
reader.close();
reader = null;
}
// at the end we need to add a poison pill to
// the queue to let the consumers know when to stop
AptaLogger.log(Level.CONFIG, this.getClreplaced(), "Added poison pill to parsing queue");
try {
queue.put(Configuration.POISON_PILL);
} catch (InterruptedException e) {
e.printStackTrace();
}
}