public void load() throws IOException {
  if (magicNumber == 0) {
    try (InputReaderLittleEndian ins=new InputReaderLittleEndian(new FileInputStreamAdapter(fileName))){
      magicNumber=ins.readLong();
      if (magicNumber != MAGIC_NUMBER)       throw new IOException("Input file is not a DAA file.");
      version=ins.readLong();
      if (version > DAA_VERSION)       throw new IOException("DAA version requires later version of MEGAN.");
      diamondBuild=ins.readLong();
      dbSeqs=ins.readLong();
      dbSeqsUsed=ins.readLong();
      dbLetters=ins.readLong();
      flags=ins.readLong();
      queryRecords=ins.readLong();
      modeRank=ins.readInt();
      gapOpen=ins.readInt();
      gapExtend=ins.readInt();
      reward=ins.readInt();
      penalty=ins.readInt();
      reserved1=ins.readInt();
      reserved2=ins.readInt();
      reserved3=ins.readInt();
      k=ins.readDouble();
      lambda=ins.readDouble();
      reserved4=ins.readDouble();
      reserved5=ins.readDouble();
      for (int i=0; i < scoreMatrix.length; i++) {
        scoreMatrix[i]=(byte)ins.read();
      }
      scoreMatrixName=Basic.toString(scoreMatrix);
      for (int i=0; i < blockSize.length; i++)       blockSize[i]=ins.readLong();
      if (blockSize[0] == 0)       throw new IOException("Invalid DAA file. DIAMOND run probably has not completed successfully.");
      for (int i=0; i < blockTypeRank.length; i++) {
        blockTypeRank[i]=(byte)ins.read();
switch (BlockType.value(blockTypeRank[i])) {
case ref_names:
          if (refNamesBlockIndex != -1)           throw new IOException("DAA file contains multiple ref_names blocks, not implemented.");
        refNamesBlockIndex=i;
      break;
case ref_lengths:
    if (refLengthsBlockIndex != -1)     throw new IOException("DAA file contains multiple ref_lengths blocks, not implemented.");
  refLengthsBlockIndex=i;
break;
case alignments:
if (alignmentsBlockIndex != -1) throw new IOException("DAA file contains multiple alignments blocks, not implemented.");
alignmentsBlockIndex=i;
break;
}
}
if (refNamesBlockIndex == -1) throw new IOException("DAA file contains 0 ref_names blocks, not implemented.");
if (refLengthsBlockIndex == -1) throw new IOException("DAA file contains 0 ref_lengths blocks, not implemented.");
if (alignmentsBlockIndex == -1) throw new IOException("DAA file contains 0 alignments blocks, not implemented.");
if (refLengthsBlockIndex < refNamesBlockIndex) throw new IOException("DAA file contains ref_lengths block before ref_names block, not implemented.");
headerSize=ins.getPosition();
lnK=Math.log(k);
}
 }
}

public void load ( ) throws IOException { if ( magicNumber == 0 ) { try ( InputReaderLittleEndian ins = new InputReaderLittleEndian ( new FileInputStreamAdapter ( fileName ) ) ) { magicNumber = ins . readLong ( ) ; if ( magicNumber != MAGIC_NUMBER ) throw new IOException ( "Input file is not a DAA file." ) ; version = ins . readLong ( ) ; if ( version > DAA_VERSION ) throw new IOException ( "DAA version requires later version of MEGAN." ) ; diamondBuild = ins . readLong ( ) ; dbSeqs = ins . readLong ( ) ; dbSeqsUsed = ins . readLong ( ) ; dbLetters = ins . readLong ( ) ; flags = ins . readLong ( ) ; queryRecords = ins . readLong ( ) ; modeRank = ins . readInt ( ) ; gapOpen = ins . readInt ( ) ; gapExtend = ins . readInt ( ) ; reward = ins . readInt ( ) ; penalty = ins . readInt ( ) ; reserved1 = ins . readInt ( ) ; reserved2 = ins . readInt ( ) ; reserved3 = ins . readInt ( ) ; k = ins . readDouble ( ) ; lambda = ins . readDouble ( ) ; reserved4 = ins . readDouble ( ) ; reserved5 = ins . readDouble ( ) ; for ( int i = 0 ; i < scoreMatrix . length ; i ++ ) { scoreMatrix [ i ] = ( byte ) ins . read ( ) ; } scoreMatrixName = Basic . toString ( scoreMatrix ) ; for ( int i = 0 ; i < blockSize . length ; i ++ ) blockSize [ i ] = ins . readLong ( ) ; if ( blockSize [ 0 ] == 0 ) throw new IOException ( "Invalid DAA file. DIAMOND run probably has not completed successfully." ) ; for ( int i = 0 ; i < blockTypeRank . length ; i ++ ) { blockTypeRank [ i ] = ( byte ) ins . read ( ) ; switch ( BlockType . value ( blockTypeRank [ i ] ) ) { case ref_names : if ( refNamesBlockIndex != - 1 ) throw new IOException ( "DAA file contains multiple ref_names blocks, not implemented." ) ; refNamesBlockIndex = i ; break ; case ref_lengths : if ( refLengthsBlockIndex != - 1 ) throw new IOException ( "DAA file contains multiple ref_lengths blocks, not implemented." ) ; refLengthsBlockIndex = i ; break ; case alignments : if ( alignmentsBlockIndex != - 1 ) throw new IOException ( "DAA file contains multiple alignments blocks, not implemented." ) ; alignmentsBlockIndex = i ; break ; } } if ( refNamesBlockIndex == - 1 ) throw new IOException ( "DAA file contains 0 ref_names blocks, not implemented." ) ; if ( refLengthsBlockIndex == - 1 ) throw new IOException ( "DAA file contains 0 ref_lengths blocks, not implemented." ) ; if ( alignmentsBlockIndex == - 1 ) throw new IOException ( "DAA file contains 0 alignments blocks, not implemented." ) ; if ( refLengthsBlockIndex < refNamesBlockIndex ) throw new IOException ( "DAA file contains ref_lengths block before ref_names block, not implemented." ) ; headerSize = ins . getPosition ( ) ; lnK = Math . log ( k ) ; } } }
read the header of a daa file and all reference names
