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:edu.cornell.med.icb.goby.modes.TestSplicedSamHelper.java

@Test
// variation after splice
public void testSamToCompactTrickCase10NoGenome() throws IOException {

    SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-10.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_DIR, "spliced-output-alignment-10");
    importer.setOutputFile(outputFilename);
    importer.execute();/* w  w w .  j  a v  a 2 s  .  co m*/

    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());
}

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

@Test
public void testIterateSortedTwoTargetSequences() throws IOException {

    final String basename = "align-skip-to-1-contact-two-targets";
    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;
    }// w ww  .  j ava 2 s .  c  o m
    writer.setTargetLengths(targetLengths);
    // we write this alignment sorted:

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

    newEntry = prepareAlignmentEntry(0, 1, 1, 30, false, new int[0]);
    writer.appendEntry(newEntry.build());

    newEntry = prepareAlignmentEntry(0, 1, 130, 30, false, new int[] { 11, 12 });
    writer.appendEntry(newEntry.build());

    newEntry = prepareAlignmentEntry(0, 1, 135, 35, false, new int[] { 6 });
    writer.appendEntry(newEntry.build());

    newEntry = prepareAlignmentEntry(0, 2, 1, 30, false, new int[0]);
    writer.appendEntry(newEntry.build());

    newEntry = prepareAlignmentEntry(0, 2, 130, 30, false, new int[0]);
    writer.appendEntry(newEntry.build());

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

    final Int2IntMap positionMap = new Int2IntOpenHashMap();

    IterateSortedAlignmentsListImpl iterator = new IterateSortedAlignmentsListImpl() {

        @Override
        public void processPositions(int referenceIndex, int intermediatePosition,
                DiscoverVariantPositionData positionBaseInfos) {
            if (referenceIndex == 1) {
                // record only reference 1 matches.
                // store one-based positions
                positionMap.put(intermediatePosition + 1, positionBaseInfos.size());
            }
            System.out.printf("position: %d listSize: %d%n", referenceIndex, positionBaseInfos.size());

        }
    };
    iterator.iterate(basenamePath);

    for (int i = 1; i < 35; i++) {
        assertEquals("[i=" + i + "] position " + i, 1, positionMap.get(i));
    }
    for (int i = 130; i < 135; i++) {
        assertEquals("[i=" + i + "] position " + i, 1, positionMap.get(i));
    }
    for (int i = 135; i < 165; i++) {
        assertEquals("[i=" + i + "] position " + i, 2, positionMap.get(i));
    }
    for (int i = 165; i < 170; i++) {
        assertEquals("[i=" + i + "] position " + i, 1, positionMap.get(i));
    }

}

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

public String getLibCacheFilePath(FileInfo fileInfo) {
    return FilenameUtils.concat(getLibCacheDirectory(fileInfo), cacheFileName(fileInfo));
}

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

@Test
public void testSamToCompactTrickCase11() throws IOException {

    SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-11.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_DIR, "spliced-output-alignment-11");
    importer.setOutputFile(outputFilename);
    importer.execute();/*from   ww w.j  av  a  2  s  . c o m*/

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

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

From source file:eu.esdihumboldt.hale.io.project.jaxb.reader.ProjectParser.java

/**
 * Get the file location/*from   w  w  w.ja  v  a  2 s .  c om*/
 * 
 * @param file the file path (absolute or relative)
 * @param basePath the possible base path
 * 
 * @return the file location
 */
private URI getFileLocation(String file, String basePath) {
    File f = new File(file);
    if (f.exists()) {
        return f.toURI();
    } else {
        File bf = new File(FilenameUtils.concat(basePath, file));
        return bf.toURI();
    }
}

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

public String getLibCacheCompressedFilePath(FileInfo fileInfo) {
    return FilenameUtils.concat(getLibCacheDirectory(fileInfo), cacheCompressedFileName(fileInfo));

}

From source file:com.sonicle.webtop.vfs.VfsManager.java

public String createStoreFile(StoreFileType fileType, int storeId, String parentPath, String name)
        throws FileSystemException, WTException {
    FileObject tfo = null, ntfo = null;

    try {//from  w  w  w  .  j  av a2s.  com
        checkRightsOnStoreElements(storeId, "UPDATE"); // Rights check!

        tfo = getTargetFileObject(storeId, parentPath);
        if (!tfo.isFolder())
            throw new IllegalArgumentException("Please provide a valid parentPath");

        String newPath = FilenameUtils.separatorsToUnix(FilenameUtils.concat(parentPath, name));
        ntfo = getTargetFileObject(storeId, newPath);
        logger.debug("Creating store file [{}, {}]", storeId, newPath);
        if (fileType.equals(StoreFileType.FOLDER)) {
            ntfo.createFolder();
        } else {
            ntfo.createFile();
        }
        return newPath;

    } catch (Exception ex) {
        logger.warn("Error creating store file", ex);
        throw ex;
    } finally {
        IOUtils.closeQuietly(tfo);
        IOUtils.closeQuietly(ntfo);
    }
}

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

public String getLibCacheDirectory(FileInfo fileInfo) {
    return FilenameUtils.concat(FilenameUtils.concat(getLibCacheDirectory(), fileInfo.getFilename()),
            Long.toString(fileInfo.getVersion()));
}

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

public String getLibCacheDirectory() {
    return FilenameUtils.concat(
            GriffinConfig.getProperty(GriffinModule.PROPERTY_PREFIX + "LibCacheDir", "/tmp/griffin-libcache"),
            this.myServerId);
}

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

@Test
// like 9 no genome
public void testSamToCompactTrickCase12NoGenome() throws IOException {

    SAMToCompactMode importer = new SAMToCompactMode();
    importer.setInputFile("test-data/splicedsamhelper/tricky-spliced-12.sam");
    final String outputFilename = FilenameUtils.concat(BASE_TEST_DIR, "spliced-output-alignment-12");
    importer.setOutputFile(outputFilename);
    importer.execute();// w  w w . j a va2 s.  c  o  m

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

    assertEquals(15013, first.getPosition());
    assertEquals(3, first.getQueryPosition());
    assertEquals(0, first.getFragmentIndex());
    assertEquals(25, first.getQueryAlignedLength());

    assertEquals(15795, second.getPosition());
    assertEquals(28, second.getQueryPosition());
    assertEquals(1, second.getFragmentIndex());
    assertEquals(7, second.getQueryAlignedLength());
}