Modifier and Type | Class and Description |
---|---|
static interface |
IOUtils.ReaderProcessor
Closure interface used when working with
IOUtils#processReader(String) . |
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
close(Closeable c)
Closes any Object which implements the interface
Closeable and
sending any error to the logger but not forcing any explicit catching of
stream errors. |
static void |
copy(InputStream input,
OutputStream output)
Moves the bytes from input to output using a 4KB byte array.
|
static <S extends Sequence<C>,C extends Compound> |
getGCGChecksum(List<S> sequences)
Calculates GCG checksum for entire list of sequences
|
static <S extends Sequence<C>,C extends Compound> |
getGCGChecksum(S sequence)
Calculates GCG checksum for a given sequence
|
static <S extends Sequence<C>,C extends Compound> |
getGCGHeader(List<S> sequences)
Assembles a GCG file header
|
static <C extends Compound> |
getGCGType(CompoundSet<C> cs)
Determines GCG type
|
static <S extends Sequence<C>,C extends Compound> |
getIDFormat(List<S> sequences)
Creates format String for accession IDs
|
static List<String> |
getList(BufferedReader br)
Returns the contents of a buffered reader as a list of strings
|
static List<String> |
getList(File file)
Delegates to
getList(InputStream) by wrapping the File
in a valid stream. |
static List<String> |
getList(InputStream is)
Delegates to
getList(BufferedReader) by wrapping the InputStream
in a valid reader. |
static String |
getPDBCharacter(boolean web,
char c1,
char c2,
boolean similar,
char c)
Creates formatted String for a single character of PDB output
|
static String |
getPDBConservation(boolean web,
char c1,
char c2,
boolean similar)
Creates formatted String for displaying conservation in PDB output
|
static String |
getPDBLegend()
Creates formatted String for displaying conservation legend in PDB output
|
static InputStream |
openFile(File file)
For a filename this code will check the extension of the file for a
.gz extension.
|
static void |
print(String string,
File file)
Prints
string to file . |
static void |
processReader(BufferedReader br,
IOUtils.ReaderProcessor processor)
Takes in a reader and a processor, reads every line from the given
file and then invokes the processor.
|
public IOUtils()
public static void close(Closeable c)
Closeable
and
sending any error to the logger but not forcing any explicit catching of
stream errors.c
- The stream to closepublic static void copy(InputStream input, OutputStream output) throws IOException
input
- Input stream of bytesoutput
- Output stream of bytesIOException
- If anything occurs in the case of the reads and writespublic static void processReader(BufferedReader br, IOUtils.ReaderProcessor processor) throws ParserException
br
- The reader to processprocessor
- The processor to invoke on all linesParserException
- Can throw this if we cannot parse the given readerpublic static List<String> getList(BufferedReader br) throws ParserException
br
- BufferedReader to read from; will be closedParserException
- Can throw this if we cannot parse the given readerpublic static List<String> getList(InputStream is) throws ParserException
getList(BufferedReader)
by wrapping the InputStream
in a valid reader. No encoding is mentioned so if you need anything
more advanced then use the other version of this method.is
- InputStream which is a text fileParserException
- Can throw this if the file is not a file or we
cannot parse itpublic static List<String> getList(File file) throws IOException
getList(InputStream)
by wrapping the File
in a valid stream. No encoding is mentioned so if you need anything
more advanced then use the other version of this method. Since this
uses openFile(File)
this code can support GZipped and plain
files.file
- File which is a text fileIOException
public static InputStream openFile(File file) throws IOException
GZIPInputStream
. Otherwise we return a normal
FileInputStream
.file
- File which may or may not be GZippedIOExceptio
- nIOException
public static <S extends Sequence<C>,C extends Compound> int getGCGChecksum(List<S> sequences)
sequences
- list of sequencespublic static <S extends Sequence<C>,C extends Compound> int getGCGChecksum(S sequence)
sequence
- given sequencepublic static <S extends Sequence<C>,C extends Compound> String getGCGHeader(List<S> sequences)
sequences
- list of sequencespublic static <C extends Compound> String getGCGType(CompoundSet<C> cs)
cs
- compound set of sequencespublic static <S extends Sequence<C>,C extends Compound> String getIDFormat(List<S> sequences)
sequences
- list of sequencespublic static String getPDBCharacter(boolean web, char c1, char c2, boolean similar, char c)
web
- true for HTML displayc1
- character in first sequencec2
- character in second sequencesimilar
- true if c1 and c2 are considered similar compoundsc
- character to displaypublic static String getPDBConservation(boolean web, char c1, char c2, boolean similar)
web
- true for HTML displayc1
- character in first sequencec2
- character in second sequencesimilar
- true if c1 and c2 are considered similar compoundspublic static String getPDBLegend()
public static void print(String string, File file) throws IOException
string
to file
.IOException
- If any I/O exception occurs while printing; this method does not catch any exceptionsCopyright © 2000–2019 BioJava. All rights reserved.