Class Ccp4Header
java.lang.Object
org.biojava.nbio.structure.io.density.Ccp4Header
Recognises CCP4/MRC map files by their header.
This is a cheap but effective guard against a cached file that is not
actually a map. A misbehaving or overloaded server can answer with an HTML
error page and an HTTP 200, in which case nothing about the status code or the
content length reveals the problem — but the missing MAP
stamp does, turning a silent failure into a clean cache miss.
- Since:
- 7.3.0
- Author:
- Amr ALHOSSARY
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe stamp itself: the three letters of "MAP" followed by a space.static final intByte offset of the four-character format stamp within a CCP4/MRC header. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether a file is a CCP4/MRC map.static booleanisCcp4(InputStream in) Checks whether a stream carries a CCP4/MRC map header.static booleanisCcp4Quietly(File file) Same asisCcp4(File)but reports a problem rather than propagating it, for use in cache-validity checks where an unreadable file and an invalid one lead to the same action.
-
Field Details
-
MAP_STAMP_OFFSET
public static final int MAP_STAMP_OFFSETByte offset of the four-character format stamp within a CCP4/MRC header. It sits in word 53 of the 256-word header.- See Also:
-
MAP_STAMP
The stamp itself: the three letters of "MAP" followed by a space.- See Also:
-
-
Method Details
-
isCcp4
Checks whether a file is a CCP4/MRC map. Gzipped files are decompressed on the fly, so.map.gzworks as well as.ccp4.- Parameters:
file- the file to check- Returns:
trueif the CCP4 stamp is present- Throws:
IOException- if the file could not be read
-
isCcp4
Checks whether a stream carries a CCP4/MRC map header. The stream is read from its current position and is not closed; it is not un-read afterwards, so pass a fresh stream or one that supports marking.- Parameters:
in- the stream to check, already decompressed- Returns:
trueif the CCP4 stamp is present- Throws:
IOException- if the stream could not be read
-
isCcp4Quietly
Same asisCcp4(File)but reports a problem rather than propagating it, for use in cache-validity checks where an unreadable file and an invalid one lead to the same action.- Parameters:
file- the file to check- Returns:
trueif the file is readable and carries the CCP4 stamp
-