Skip to content

Commit

Permalink
Removed redundant readability test in unrollPaths method (#1355)
Browse files Browse the repository at this point in the history
* - removed redundant readability test in unrollPaths method
* - responding to unrelated request
  • Loading branch information
Yossi Farjoun authored May 20, 2019
1 parent e2c0fdd commit 64e98d6
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions src/main/java/htsjdk/samtools/util/IOUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package htsjdk.samtools.util;


import htsjdk.samtools.Defaults;
import htsjdk.samtools.SAMException;
import htsjdk.samtools.seekablestream.SeekableBufferedStream;
Expand All @@ -33,15 +32,48 @@
import htsjdk.samtools.util.nio.DeleteOnExitPathHook;
import htsjdk.tribble.Tribble;

import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.*;
import java.nio.file.FileSystemNotFoundException;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.Deflater;
Expand Down Expand Up @@ -1058,7 +1090,7 @@ private static List<String> tokenSlurp(final InputStream is, final Charset charS
*/
public static List<File> unrollFiles(final Collection<File> inputs, final String... extensions) {
Collection<Path> paths = unrollPaths(filesToPaths(inputs), extensions);
return paths.stream().map(p->p.toFile()).collect(Collectors.toList());
return paths.stream().map(Path::toFile).collect(Collectors.toList());
}

/**
Expand Down Expand Up @@ -1086,8 +1118,6 @@ public static List<Path> unrollPaths(final Collection<Path> inputs, final String

// If the file didn't match a given extension, treat it as a list of files
if (!matched) {
IOUtil.assertFileIsReadable(p);

try {
Files.lines(p)
.map(String::trim)
Expand All @@ -1098,16 +1128,16 @@ public static List<Path> unrollPaths(final Collection<Path> inputs, final String
innerPath = getPath(s);
stack.push(innerPath);
} catch (IOException e) {
throw new IllegalArgumentException("cannot convert " + s + " to a Path.");
throw new IllegalArgumentException("cannot convert " + s + " to a Path.", e);
}
}
);

} catch (IOException e) {
throw new IllegalArgumentException("had trouble reading from " + p.toUri().toString());
throw new IllegalArgumentException("had trouble reading from " + p.toUri().toString(), e);
}
}
}
}

// Preserve input order (since we're using a stack above) for things that care
Collections.reverse(output);
Expand Down

0 comments on commit 64e98d6

Please sign in to comment.