001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021package org.biojava.nbio.structure.secstruc; 022 023import org.biojava.nbio.structure.ResidueNumber; 024import org.biojava.nbio.structure.ResidueRangeAndLength; 025 026/** 027 * A secondary structure element (SSE) is an object representing a block of 028 * sequential residues that share the same secondary structure type. 029 * 030 * @author Aleix Lafita 031 * @since 4.1.1 032 * 033 */ 034public class SecStrucElement { 035 036 private SecStrucType type; 037 private ResidueRangeAndLength range; 038 private int index; 039 040 /** 041 * Create a new SSE object. The start and end residue numbers cannot be the 042 * same. 043 * 044 * @param type 045 * object describing the type of SS 046 * @param start 047 * first residue of the SSE 048 * @param end 049 * final residue of the SSE 050 * @param length 051 * number of residues included in the SSE 052 * @param index 053 * @param chainID 054 * the chain ID 055 */ 056 public SecStrucElement(SecStrucType type, ResidueNumber start, 057 ResidueNumber end, int length, int index, String chainID) { 058 059 this.type = type; 060 this.index = index; 061 range = new ResidueRangeAndLength(chainID, start, end, length); 062 } 063 064 /** 065 * Returns the {@link SecStrucType} of this element. 066 * 067 * @return 068 */ 069 public SecStrucType getType() { 070 return type; 071 } 072 073 /** 074 * Returns the index of the SSE for its type. This is, the sequential 075 * position of this SSE relative to the other SSE of the same type. 076 * 077 * @return 078 */ 079 public int getIndex() { 080 return index; 081 } 082 083 /** 084 * Return the length (number of residues) in the SSE. 085 * 086 * @return 087 */ 088 public int getLength() { 089 return range.getLength(); 090 } 091 092 /** 093 * Returns the ID of this element. The ID is the concatenation of the type 094 * letter and the numerical element identifier (e.g. H1, S1, ...). 095 * 096 * @return 097 */ 098 public String getId() { 099 return type.toString() + index + ""; 100 } 101 102 /** 103 * Returns the residue range of this SSE. 104 * 105 * @return 106 */ 107 public ResidueRangeAndLength getRange() { 108 return range; 109 } 110 111 @Override 112 public String toString() { 113 return getId() + ": " + range.toString(); 114 } 115 116}