public static void main(String[] args) {

    try {
      UniprotProxySequenceReader<AminoAcidCompound> uniprotSequence =
          new UniprotProxySequenceReader<AminoAcidCompound>(
              "YA745_GIBZE", AminoAcidCompoundSet.getAminoAcidCompoundSet());
      ProteinSequence proteinSequence = new ProteinSequence(uniprotSequence);
      logger.info("Accession: {}", proteinSequence.getAccession().getID());
      logger.info("Sequence: {}", proteinSequence.getSequenceAsString());
    } catch (Exception e) {
      logger.error("Exception: ", e);
    }
  }
Example #2
0
  public static void writeProteinSequence(ProteinSequence sequence, DataOutput out)
      throws IOException {

    String string = sequence.getSequenceAsString();

    out.writeInt(string.length());

    for (int i = 0; i < string.length(); i += 3) {
      String substring = string.substring(i, Math.min(i + 3, string.length()));
      int value = 0;
      for (int j = 0; j < 3; j++) {
        value += (j < substring.length() ? getSerializedAminoAcid(substring.charAt(j)) : 0);
        if (j != 2) {
          value <<= 5;
        }
      }
      out.writeShort(value);
    }
  }