Skip to main content

BAM import issues

Comments

2 comments

  • Matthew Cheung

    Hi there,

    Our SAM/BAM importer needs to have both the BAM file and reference passed to its DocumentFileImporter.importDocumentsFromMultipleFilesReturningUnimported() method.

    Unfortunately this doesn't get used by any of our convenience utility classes, so you'll need to use it directly.  Here is an example of how you can do it.

    // Get importer
    DocumentFileImporter importer = PluginUtilities.getDocumentFileImporters().stream()
    .filter(imp ->
    Arrays.stream(imp.getPermissibleExtensions()).anyMatch(extension -> extension.equalsIgnoreCase(".bam"))
    ).findFirst()
    .orElseThrow(() -> new DocumentOperationException("No BAM importer available"));

    // Create a ImportCallback that stores the results in an ArrayList
    List<AnnotatedPluginDocument> imported = new ArrayList<>();
    DocumentFileImporter.ImportCallback callback = new DocumentFileImporter.ImportCallback() {
    @Override
    public AnnotatedPluginDocument addDocument(PluginDocument document) {
    AnnotatedPluginDocument apd = DocumentUtilities.createAnnotatedPluginDocument(document);
    imported.add(apd);
    return apd;
    }

    @Override
    public AnnotatedPluginDocument addDocument(AnnotatedPluginDocument annotatedDocument) {
    imported.add(annotatedDocument);
    return annotatedDocument;
    }
    };

    // Call the importers method directly and then add the results to the destination folder
    List<File> unused = importer.importDocumentsFromMultipleFilesReturningUnimported(importerP.getOptions(files, ProgressListener.EMPTY), files, callback, ProgressListener.EMPTY);
    for (AnnotatedPluginDocument toAdd : imported) {
    destination.addDocumentCopy(toAdd, ProgressListener.EMPTY);
    }

     

     

    0
  • Dave OConnor

    Thanks - this got me unstuck and its working now!

    0

Please sign in to leave a comment.