Example usage for org.apache.commons.io FilenameUtils concat

List of usage examples for org.apache.commons.io FilenameUtils concat

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils concat.

Prototype

public static String concat(String basePath, String fullFilenameToAdd) 

Source Link

Document

Concatenates a filename to a base path using normal command line style rules.

Usage

From source file:de.sub.goobi.export.dms.AutomaticDmsExportWithoutHibernate.java

/**
 * Starts copying all directories configured in goobi_config.properties
 * parameter "processDirs" to export folder.
 *
 * @param myProcess//w w w. j  ava 2  s. com
 *            the process object
 * @param zielVerzeichnis
 *            the destination directory
 */
private void directoryDownload(ProcessObject myProcess, String zielVerzeichnis) throws IOException {
    String[] processDirs = ConfigCore.getStringArrayParameter("processDirs");

    for (String processDir : processDirs) {

        SafeFile srcDir = new SafeFile(FilenameUtils.concat(fi.getProcessDataDirectory(),
                processDir.replace("(processtitle)", myProcess.getTitle())));
        SafeFile dstDir = new SafeFile(FilenameUtils.concat(zielVerzeichnis,
                processDir.replace("(processtitle)", myProcess.getTitle())));

        if (srcDir.isDirectory()) {
            srcDir.copyDir(dstDir);
        }
    }
}

From source file:net.sf.jvifm.ui.FileLister.java

public String[] getSelectionFiles() {
    TableItem[] items = table.getSelection();
    String[] result = new String[items.length];

    for (int i = 0; i < items.length; i++) {
        result[i] = FilenameUtils.concat(pwd, items[i].getText(0));
    }/* ww w  .j av a 2  s  .  c  o  m*/
    return result;

}

From source file:edu.cornell.med.icb.goby.readers.sam.TestGobyPaperTop5000s.java

/**
 * Test that SHOULD fail, for local testing, not for server testing.
 * This is designed to be run manually as the 1M doesn't exist on the testing server.
 * Before running this test, run testRoundTrip1M().
 *
 * @throws java.io.IOException error/*w w  w .j a  v  a  2  s  .c  o  m*/
 */
// @Test
public void testRoundTripFail() throws IOException {
    final RoundTripAlignment rtc = new RoundTripAlignment();
    rtc.sourceBamFilename = FilenameUtils.concat(BASE_TEST_INPUT_DIR, "HZFWPTI-5000.sam.gz");
    rtc.destBamFilename = FilenameUtils.concat(BASE_TEST_INPUT_DIR, "JRODTYG-5000.sam.gz");
    rtc.convertBamToGoby = false;
    rtc.convertGobyToBam = false;
    rtc.testRoundTripAny();
}

From source file:ddf.content.plugin.video.VideoThumbnailPlugin.java

private String getThumbnailFilePath() {
    final long threadId = Thread.currentThread().getId();

    // FFmpeg replaces the "%1d" with a single digit when it creates the output file. This is
    // necessary because FFmpeg requires a unique filename for each output file when outputting
    // multiple images.
    final String thumbnailFileName = String.format("thumbnail-%d-%%1d.png", threadId);

    final String tempDirectoryPath = System.getProperty("java.io.tmpdir");

    return FilenameUtils.concat(tempDirectoryPath, thumbnailFileName);
}

From source file:com.iyonger.apm.web.controller.FileEntryController.java

private void upload(User user, String path, String description, MultipartFile file) throws IOException {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setContentBytes(file.getBytes());
    fileEntry.setDescription(description);
    fileEntry.setPath(FilenameUtils.separatorsToUnix(FilenameUtils.concat(path, file.getOriginalFilename())));
    fileEntryService.save(user, fileEntry);
}

From source file:edu.cornell.med.icb.goby.modes.TestSplicedSamHelper.java

@Test
public void testSamToCompactTrickCase8() throws IOException {

    SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-8.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_DIR, "spliced-output-alignment-8");
    importer.setOutputFile(outputFilename);
    MutableString seq = new MutableString();
    for (int i = 0; i < 194407 - 7; i++) {
        seq.append('N');
    }/*w w w.j  a va2  s.com*/
    seq.append("NNNNNNTTAGAAAAACAGAGAGAGAAGGAGAGTAAAGGGAGGAGGCGGAGGAGGAGAAAAGAAGAAAGCAGAGANNNNNN");
    String[] refs = { seq.toString() };

    RandomAccessSequenceTestSupport genomeTestSupport = new RandomAccessSequenceTestSupport(refs);
    importer.setGenome(genomeTestSupport);

    importer.execute();

    AlignmentReader reader = new AlignmentReaderImpl(outputFilename);
    assertTrue(reader.hasNext());
    Alignments.AlignmentEntry first = reader.next();

    assertEquals(0, first.getQueryIndex());
    assertEquals(0, first.getFragmentIndex());
    assertEquals(194301 - 1, first.getPosition());

}

From source file:com.turn.griffin.GriffinLibCacheUtil.java

public boolean finishTempCachePreparation(FileInfo fileInfo) {

    /* Decompress the file */
    decompressFile(getTempCacheCompressedFilePath(fileInfo),
            GriffinCompression.getByName(fileInfo.getCompression()));

    /* Verification */
    String fileHash = computeMD5(getTempCacheFilePath(fileInfo)).get();
    if (!fileInfo.getHash().equals(fileHash)) {
        logger.warn(String.format("File verification for downloaded file failed %s",
                fileInfo.toString().replaceAll(System.getProperty("line.separator"), " ")));
        logger.debug(String.format("Expected hash: %s actual hash: %s", fileInfo.getHash(), fileHash));
        if (logger.isDebugEnabled()) {
            try {
                /* Store file for forensics */
                String tempDir = FilenameUtils.concat(getTempCacheDirectory(), fileInfo.getFilename());
                FileUtils.copyDirectoryToDirectory(new File(tempDir), new File(getForensicCacheDirectory()));
            } catch (IOException e) {
                // Ignore
            }//from  ww  w.  j  a  v a2  s .c  o m
        }
        return false;
    }
    return true;
}

From source file:edu.cornell.med.icb.goby.readers.sam.TestSamRecordParser.java

/**
 * Same test as above, but write the sam to compact and then read the sequence variation form the compact.
 *
 * @throws IOException error reading//from   w  w  w  . j  a  v a 2s .  c  om
 */
@Test
public void testSamToCompactTrickCase17ViaWriter() throws IOException {
    final SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-17.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_OUTPUT_DIR, "tricky-spliced-17");
    importer.setPreserveSoftClips(true);
    importer.setOutputFile(outputFilename);
    importer.execute();

    final AlignmentReader reader = new AlignmentReaderImpl(outputFilename);
    assertTrue(reader.hasNext());
    final Alignments.AlignmentEntry first = reader.next();

    assertEquals(45881869 - 1, first.getPosition());

    //509.6.68.19057.157284   83   chr1   45881869   29   6S23M1I6M1D16M1I47M   =   45881519   -443   TTACCCGCTTTCCTTGCCCAAATTTTAAGTTTCNGGAAAAGGGGAGGGAAATGGGTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTGTGACAGAGTGTCAC   #######################################################ECGGGGGGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHHH   MD:Z:3G4A7C4C1A2T2^T2C4T3A0G5C44   RG:Z:1   XG:i:3   AM:i:29   NM:i:14   SM:i:29   XM:i:10   XO:i:3   XT:A:M

    assertEquals(6, first.getQueryPosition());
    assertEquals("TTACCC", first.getSoftClippedBasesLeft());
    assertEquals("", first.getSoftClippedBasesRight());

    assertEquals(13, first.getSequenceVariationsCount());

    final Alignments.SequenceVariation last = first.getSequenceVariations(12);
    assertEquals("T", last.getTo());
    assertEquals("C", last.getFrom());
    assertArrayEquals(RoundTripAlignment.byteArray(36), last.getToQuality().toByteArray());
}

From source file:edu.cornell.med.icb.goby.alignments.TestIterateSortedAlignment.java

@Test
public void testIterateSortedWithReadInsertions() throws IOException {

    final String basename = "align-skip-to-1-concat";
    final String basenamePath = FilenameUtils.concat(BASE_TEST_DIR, basename);
    final AlignmentWriterImpl writer = new AlignmentWriterImpl(basenamePath);
    writer.setNumAlignmentEntriesPerChunk(1);

    final int numTargets = 3;
    final int[] targetLengths = new int[numTargets];

    for (int referenceIndex = 0; referenceIndex < numTargets; referenceIndex++) {
        targetLengths[referenceIndex] = 1000;
    }//from  w  w  w  .j av a  2 s .c o  m
    writer.setTargetLengths(targetLengths);
    // we write this alignment sorted:

    writer.setSorted(true);
    Alignments.AlignmentEntry.Builder newEntry;

    newEntry = prepareAlignmentEntryWithReadInsertion(0, 1, 100, 30, false, new int[] { 4, 3 });
    writer.appendEntry(newEntry.build());

    writer.close();
    writer.printStats(System.out);

    final Int2IntMap positionMap = new Int2IntOpenHashMap();
    final Int2IntMap readIndexMap = new Int2IntOpenHashMap();

    IterateSortedAlignmentsListImpl iterator = new IterateSortedAlignmentsListImpl() {

        @Override
        public void processPositions(int referenceIndex, int intermediatePosition,
                DiscoverVariantPositionData positionBaseInfos) {
            int coverage = 0;
            for (PositionBaseInfo info : positionBaseInfos) {
                coverage += info.from != '-' ? 1 : 0;
                readIndexMap.put(info.readIndex, readIndexMap.get(info.readIndex) + 1);
            }
            // store one-based positions
            positionMap.put(intermediatePosition + 1, coverage);
            //    System.out.printf("position: %d listSize: %d%n", position, coverage);
        }
    };
    iterator.iterate(basenamePath);
    // check coverage on ref:
    for (int i = 0; i < 100; i++) {
        assertEquals("position " + i, 0, positionMap.get(i));
    }
    for (int i = 100; i < 132; i++) {

        assertEquals("position " + i, 1, positionMap.get(i));
    }
    //check read index:
    for (int i = 1; i < 35; i++) {
        assertEquals("read-index " + i, 1, readIndexMap.get(i));

    }

}

From source file:edu.cornell.med.icb.goby.modes.TestSplicedSamHelper.java

@Test
public void testSamToCompactTrickCase9() throws IOException {

    SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-9.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_DIR, "spliced-output-alignment-9");
    importer.setOutputFile(outputFilename);
    MutableString seq = new MutableString();

    seq.append("NNNTTAGAAAAACAGAGAGAGAAGGAGAGTAAAGGGAGGAGGCGGAGGAGGAGAAAAGAAGAAAGCAGAGANNNNNN");
    for (int i = 0; i < 573; i++) {
        seq.insert(25, '-');
    }/*from   w  w  w  . ja  v a  2s . c  o  m*/
    String[] refs = { seq.toString() };

    RandomAccessSequenceTestSupport genomeTestSupport = new RandomAccessSequenceTestSupport(refs);
    importer.setGenome(genomeTestSupport);

    importer.execute();

    AlignmentReader reader = new AlignmentReaderImpl(outputFilename);
    assertTrue(reader.hasNext());
    Alignments.AlignmentEntry first = reader.next();

    assertEquals(0, first.getQueryIndex());
    assertEquals(0, first.getFragmentIndex());
    assertEquals(3 - 1, first.getPosition());

}