use of java.nio.file.Files in project hmftools by hartwigmedical.
the class FilteredSVWriter method processVcfFiles.
public void processVcfFiles() {
final List<File> vcfFiles;
final Path root = Paths.get(mVcfFileLocation);
try (final Stream<Path> stream = Files.walk(root, 5, FileVisitOption.FOLLOW_LINKS)) {
vcfFiles = stream.map(p -> p.toFile()).filter(p -> !p.isDirectory()).filter(p_ -> p_.getName().endsWith("somaticSV_bpi.vcf")).collect(Collectors.toList());
LOGGER.debug("found {} BPI VCF files", vcfFiles.size());
// add the filtered and passed SV entries for each file
for (final File vcfFile : vcfFiles) {
if (vcfFile.isDirectory())
continue;
if (!vcfFile.getPath().contains("structuralVariants/bpi/"))
continue;
if (!vcfFile.getName().endsWith("somaticSV_bpi.vcf"))
continue;
LOGGER.debug("BPI VCF path({}) file({})", vcfFile.getPath(), vcfFile.getName());
// extract sampleId from the directory or file name
String[] itemsStr = vcfFile.getName().split("_");
if (itemsStr.length != 4)
continue;
String sampleId = itemsStr[1];
LOGGER.debug("sampleId({})", sampleId);
List<StructuralVariant> variants = readFromVcf(vcfFile.getPath());
generateFilteredSVFile(variants, sampleId);
}
if (mFileWriter != null)
mFileWriter.close();
} catch (Exception e) {
}
}
use of java.nio.file.Files in project hmftools by hartwigmedical.
the class SvVCFAnnotator method processVcfFiles.
public void processVcfFiles() {
final List<File> vcfFiles;
final Path root = Paths.get(mVcfFileLocation);
try (final Stream<Path> stream = Files.walk(root, 5, FileVisitOption.FOLLOW_LINKS)) {
vcfFiles = stream.map(p -> p.toFile()).filter(p -> !p.isDirectory()).filter(p_ -> p_.getName().endsWith("somaticSV_bpi.vcf")).collect(Collectors.toList());
LOGGER.debug("found {} BPI VCF files", vcfFiles.size());
// add the filtered and passed SV entries for each file
for (final File vcfFile : vcfFiles) {
if (vcfFile.isDirectory())
continue;
if (!vcfFile.getPath().contains("structuralVariants/bpi/"))
continue;
if (!vcfFile.getName().endsWith("somaticSV_bpi.vcf"))
continue;
LOGGER.debug("BPI VCF path({}) file({})", vcfFile.getPath(), vcfFile.getName());
// extract sampleId from the directory or file name
String[] itemsStr = vcfFile.getName().split("_");
if (itemsStr.length != 4)
continue;
String sampleId = itemsStr[1];
LOGGER.debug("sampleId({})", sampleId);
List<VariantContext> variants = readFromVcf(vcfFile.getPath());
for (final VariantContext variant : variants) {
if (variant.hasAttribute("IMPRECISE")) {
LOGGER.debug("var({}) has imprecise call", variant.getID());
}
}
// generateFilteredSVFile(variants, sampleId);
}
if (mFileWriter != null)
mFileWriter.close();
} catch (Exception e) {
}
}
use of java.nio.file.Files in project support-core-plugin by jenkinsci.
the class OtherConfigFilesComponentTest method missingFile.
@Test
public void missingFile() throws Exception {
File file = new File(j.jenkins.root, "x.xml");
FileUtils.writeStringToFile(file, xml);
Map<String, Content> contents = new HashMap<>();
new OtherConfigFilesComponent().addContents(new Container() {
@Override
public void add(Content content) {
contents.put(MessageFormat.format(content.getName(), (Object[]) content.getFilterableParameters()), content);
}
});
Files.delete(file.toPath());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Content content = contents.get("jenkins-root-configuration-files/x.xml");
assertNotNull(content);
content.writeTo(baos);
assertThat("routine build should not issue warnings", logging.getRecords().stream().filter(// TODO .record(…, WARNING) does not accomplish this
lr -> lr.getLevel().intValue() >= Level.WARNING.intValue()).map(lr -> lr.getSourceClassName() + "." + lr.getSourceMethodName() + ": " + lr.getMessage()).collect(// LogRecord does not override toString
Collectors.toList()), emptyIterable());
assertThat(baos.toString(), allOf(containsString("FileNotFoundException"), containsString(file.getAbsolutePath())));
}
use of java.nio.file.Files in project keycloak by keycloak.
the class CopyDependencies method main.
public static void main(String[] args) throws IOException {
String version = args[2];
Path repository = new File(args[0]).toPath().resolve("org").resolve("keycloak");
Path targetRoot = new File(args[1]).toPath().resolve(version);
BufferedReader br = new BufferedReader(new InputStreamReader(CopyDependencies.class.getResourceAsStream("files")));
Path target = targetRoot;
for (String l = br.readLine(); l != null; l = br.readLine()) {
if (l.startsWith("./")) {
target = targetRoot.resolve(l.replace("./", "").replace('/', File.separatorChar));
if (!target.toFile().isDirectory()) {
target.toFile().mkdirs();
}
} else if (l.trim().length() > 0) {
String[] t = l.trim().split(":");
String artifactName = t[0];
String destName = t.length == 1 ? artifactName : t[1];
File artifactDir = repository.resolve(artifactName).resolve(version).toFile();
for (File f : artifactDir.listFiles((file, name) -> name.contains(".tar.gz") || name.contains(".zip"))) {
Files.copy(f.toPath(), target.resolve(f.getName().replace(artifactName, destName)), StandardCopyOption.REPLACE_EXISTING);
}
System.out.println(artifactName);
}
}
br.close();
}
use of java.nio.file.Files in project keycloak by keycloak.
the class TomcatDeploymentArchiveProcessorUtils method copyWarClasspathFilesToCommonTomcatClasspath.
/**
* Tomcat doesn't load files (e. g. secure-portal keystore) from webarchive classpath
* we need to copy it to common classpath /catalina_home/lib
* @param archive
*/
public static void copyWarClasspathFilesToCommonTomcatClasspath(Archive<?> archive) {
Stream<Node> contentOfArchiveClasspath = archive.getContent(archivePath -> archivePath.get().startsWith(WAR_CLASSPATH)).values().stream().filter(node -> StringUtils.countMatches(node.toString(), "/") == // get only files not directories
StringUtils.countMatches(WAR_CLASSPATH, "/") && node.toString().contains("."));
String catalinaHome = System.getProperty("app.server.home");
contentOfArchiveClasspath.forEach((Node node) -> {
Path p = Paths.get(node.toString());
File outputFile = new File(catalinaHome + "/lib/" + p.getFileName().toString());
if (!outputFile.exists()) {
try {
Files.copy(node.getAsset().openStream(), outputFile.toPath());
} catch (IOException e) {
throw new RuntimeException("Couldn't copy classpath files from deployed war to common classpath of tomcat", e);
}
}
});
}
Aggregations