001package org.biojava.nbio.structure.io; 002 003import org.biojava.nbio.structure.Structure; 004import org.biojava.nbio.structure.align.util.UserConfiguration; 005import org.biojava.nbio.structure.io.cif.CifFileConverter; 006 007import java.io.IOException; 008import java.io.InputStream; 009 010/** 011 * Parse text Cif files and provide capabilities to store them locally. 012 * @author Sebastian Bittrich <sebastian.bittrich@rcsb.org> 013 * @since 5.3.0 014 */ 015public class CifFileReader extends LocalPDBDirectory { 016 public static final String[] CIF_SPLIT_DIR = new String[] { "data", "structures", "divided", "mmCIF" }; 017 public static final String[] CIF_OBSOLETE_DIR = new String[] { "data", "structures", "obsolete", "mmCIF" }; 018 019 /** 020 * Constructs a new CifFileReader, initializing the extensions member variable. 021 * The path is initialized in the same way as {@link UserConfiguration}, 022 * i.e. to system property/environment variable {@link UserConfiguration#PDB_DIR}. 023 * Both autoFetch and splitDir are initialized to false 024 */ 025 public CifFileReader() { 026 this(null); 027 } 028 029 /** 030 * Constructs a new CifFileReader, initializing the extensions member variable. 031 * The path is initialized to the given path, both autoFetch and splitDir are initialized to false. 032 */ 033 public CifFileReader(String path) { 034 super(path); 035 addExtension(".cif"); 036 addExtension(".mmcif"); 037 addExtension(".cif.gz"); 038 addExtension(".mmcif.gz"); 039 } 040 041 @Override 042 public Structure getStructure(InputStream inStream) throws IOException{ 043 return CifFileConverter.fromInputStream(inStream, getFileParsingParameters()); 044 } 045 046 @Override 047 protected String getFilename(String pdbId) { 048 return pdbId.toLowerCase() + ".cif.gz"; 049 } 050 051 @Override 052 protected String[] getSplitDirPath() { 053 return CIF_SPLIT_DIR; 054 } 055 056 @Override 057 protected String[] getObsoleteDirPath() { 058 return CIF_OBSOLETE_DIR; 059 } 060}