From Genome Analysis Wiki
Jump to navigationJump to search
975 bytes removed
, 18:05, 23 June 2010
Line 1: |
Line 1: |
| = InputFile / IFILE = | | = InputFile / IFILE = |
− | This is our class for file operations. It hides the underlying file structure from the user. That way code can generically open and operate on a file using the exact same interface without having to know if the file is standard, gzip, or bgzf format. | + | This is our class for file operations. It hides the underlying file structure from the user. That way code can generically open and operate on a file using the exact same interface without having to know if the file is standard, gzip, or bgzf format (at least for reading - for writing the user has to specify which type to open). |
− | | |
− | | |
− | === static Class Methods ===
| |
− | {| style="margin: 1em 1em 1em 0; background-color: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" border="1"
| |
− | |-style="background: #f2f2f2; text-align: center;"
| |
− | ! Method Name !! Description
| |
− | |-
| |
− | | void InputFile::setWriteFileType(FileTypeEnum fileType)
| |
− | | Set the type of file to open when opening a file for write.
| |
− | Must be called prior to calling ifopen().
| |
− | | |
− | Defaults to [[C++ Class: InputFile#ClassEnums|DEFAULT]] which determines the file type from the extension when opening a file for write.
| |
− | |}
| |
− | | |
− | ==== Using the static methods ====
| |
− | Here is an example of using setWriteFileType (writes a glf as a standard file rather than in bgzf which would be the default):
| |
− | <source lang="cpp">
| |
− | InputFile::setWriteFileType(InputFile::STD);
| |
− | std::string filename = "results/stdFile.glf";
| |
− | | |
− | filePtr = ifopen(filename.c_str(), "wt");
| |
− | assert(filePtr != NULL);
| |
− |
| |
− | assert(ifwrite(filePtr,
| |
− | IFILE_Test::TEST_FILE_CONTENTS.c_str(),
| |
− | IFILE_Test::TEST_FILE_CONTENTS.length())
| |
− | == IFILE_Test::TEST_FILE_CONTENTS.length());
| |
− |
| |
− | assert(ifclose(filePtr) == 0);
| |
− | </source>
| |
| | | |
| | | |
Line 48: |
Line 18: |
| ! Enum Value !! Description | | ! Enum Value !! Description |
| |- | | |- |
− | ! colspan="2"| enum FileTypeEnum | + | ! colspan="2"| enum ifileCompression |
| |- | | |- |
| | DEFAULT | | | DEFAULT |
| | Use the default method for determining file type. | | | Use the default method for determining file type. |
| + | Opens as UNCOMPRESSED unless the filename ends in ".gz", then opened as GZIP |
| |- | | |- |
− | | STD | + | | UNCOMPRESSED |
− | | Standard File Type. | + | | Standard Uncompressed File Type. |
| |- | | |- |
− | | GZ | + | | GZIP |
| | Gzip File Type. | | | Gzip File Type. |
| |- | | |- |