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.aaproperties.profeat;
022
023import org.biojava.nbio.aaproperties.profeat.IProfeatProperties.ATTRIBUTE;
024import org.biojava.nbio.aaproperties.profeat.IProfeatProperties.DISTRIBUTION;
025import org.biojava.nbio.aaproperties.profeat.IProfeatProperties.GROUPING;
026import org.biojava.nbio.aaproperties.profeat.IProfeatProperties.TRANSITION;
027import org.biojava.nbio.core.sequence.ProteinSequence;
028
029import java.util.Map;
030
031/**
032 * This is an adaptor class which enable the ease of generating profeat properties.
033 * At least one adaptor method is written for each available properties provided in IProfeatProperties.
034 *
035 * @author kohchuanhock
036 * @version 2011.06.16
037 * @since 3.0.2
038 * @see IProfeatProperties
039 * @see ProfeatPropertiesImpl
040 */
041public class ProfeatProperties {
042        /**
043         * An adaptor method which returns the composition of the specific grouping for the given attribute.
044         *
045         * @param sequence
046         *      a protein sequence consisting of non-ambiguous characters only
047         * @param attribute
048         *      one of the seven attributes (Hydrophobicity, Volume, Polarity, Polarizability, Charge, SecondaryStructure or SolventAccessibility)
049         * @param group
050         *      the grouping to be computed
051         * @return
052         *      returns the composition of the specific grouping for the given attribute
053         * @throws Exception
054         *      throws Exception if attribute or group are unknown
055         */
056        public static double getComposition(ProteinSequence sequence, ATTRIBUTE attribute, GROUPING group) throws Exception{
057                return new ProfeatPropertiesImpl().getComposition(sequence, attribute, group);
058        }
059
060        public static Map<GROUPING, Double> getComposition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception{
061                return new ProfeatPropertiesImpl().getComposition(sequence, attribute);
062        }
063
064        public static Map<ATTRIBUTE, Map<GROUPING, Double>> getComposition(ProteinSequence sequence) throws Exception{
065                return new ProfeatPropertiesImpl().getComposition(sequence);
066        }
067
068        public static double getComposition(String sequence, ATTRIBUTE attribute, GROUPING group) throws Exception{
069                return ProfeatProperties.getComposition(new ProteinSequence(sequence), attribute, group);
070        }
071
072        public static Map<GROUPING, Double> getComposition(String sequence, ATTRIBUTE attribute) throws Exception{
073                return ProfeatProperties.getComposition(new ProteinSequence(sequence), attribute);
074        }
075
076        public static Map<ATTRIBUTE, Map<GROUPING, Double>> getComposition(String sequence) throws Exception{
077                return ProfeatProperties.getComposition(new ProteinSequence(sequence));
078        }
079
080        /**
081         * An adaptor method which returns the number of transition between the specified groups for the given attribute with respect to the length of sequence.
082         *
083         * @param sequence
084         *      a protein sequence consisting of non-ambiguous characters only
085         * @param attribute
086         *      one of the seven attributes (Hydrophobicity, Volume, Polarity, Polarizability, Charge, SecondaryStructure or SolventAccessibility)
087         * @param transition
088         *      the interested transition between the groups
089         * @return
090         *  returns the number of transition between the specified groups for the given attribute with respect to the length of sequence.
091         * @throws Exception
092         *      throws Exception if attribute or group are unknown
093         */
094        public static double getTransition(ProteinSequence sequence, ATTRIBUTE attribute, TRANSITION transition) throws Exception{
095                return new ProfeatPropertiesImpl().getTransition(sequence, attribute, transition);
096        }
097
098        public static Map<TRANSITION, Double> getTransition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception{
099                return new ProfeatPropertiesImpl().getTransition(sequence, attribute);
100        }
101
102        public static Map<ATTRIBUTE, Map<TRANSITION, Double>> getTransition(ProteinSequence sequence) throws Exception{
103                return new ProfeatPropertiesImpl().getTransition(sequence);
104        }
105
106        public static double getTransition(String sequence, ATTRIBUTE attribute, TRANSITION transition) throws Exception{
107                return ProfeatProperties.getTransition(new ProteinSequence(sequence), attribute, transition);
108        }
109
110        public static Map<TRANSITION, Double> getTransition(String sequence, ATTRIBUTE attribute) throws Exception{
111                return ProfeatProperties.getTransition(new ProteinSequence(sequence), attribute);
112        }
113
114        public static Map<ATTRIBUTE, Map<TRANSITION, Double>> getTransition(String sequence) throws Exception{
115                return ProfeatProperties.getTransition(new ProteinSequence(sequence));
116        }
117
118        /**
119         * An adaptor method which computes and return the position with respect to the sequence where the given distribution of the grouping can be found.<br/>
120         * Example: "1111122222"<br/>
121         * For the above example,<br/>
122         * position of the GROUPING.GROUP1 && DISTRIBUTION.FIRST = 0/10 (because the first occurrence of '1' is at position 0)<br/>
123         * position of the GROUPING.GROUP1 && DISTRIBUTION.ALL = 4/10 (because all occurrences of '1' happens on and before position 4)<br/>
124         *
125         * @param sequence
126         *      a protein sequence consisting of non-ambiguous characters only
127         * @param attribute
128         *      one of the seven attributes (Hydrophobicity, Volume, Polarity, Polarizability, Charge, SecondaryStructure or SolventAccessibility)
129         * @param group
130         *      one the three groups for the attribute
131         * @param distribution
132         *      the distribution of the grouping
133         *
134         * @return
135         *      the position with respect to the length of sequence where the given distribution of the grouping can be found.<br/>
136         * @throws Exception
137         *      throws Exception if attribute or group are unknown
138         */
139        public static double getDistributionPosition(ProteinSequence sequence, ATTRIBUTE attribute, GROUPING group, DISTRIBUTION distribution) throws Exception{
140                return new ProfeatPropertiesImpl().getDistributionPosition(sequence, attribute, group, distribution);
141        }
142
143        public static Map<DISTRIBUTION, Double> getDistributionPosition(ProteinSequence sequence, ATTRIBUTE attribute, GROUPING group) throws Exception{
144                return new ProfeatPropertiesImpl().getDistributionPosition(sequence, attribute, group);
145        }
146
147        public static Map<GROUPING, Map<DISTRIBUTION, Double>> getDistributionPosition(ProteinSequence sequence, ATTRIBUTE attribute) throws Exception{
148                return new ProfeatPropertiesImpl().getDistributionPosition(sequence, attribute);
149        }
150
151        public static Map<ATTRIBUTE , Map<GROUPING, Map<DISTRIBUTION, Double>>> getDistributionPosition(ProteinSequence sequence) throws Exception{
152                return new ProfeatPropertiesImpl().getDistributionPosition(sequence);
153        }
154
155        public static double getDistributionPosition(String sequence, ATTRIBUTE attribute, GROUPING group, DISTRIBUTION distribution) throws Exception{
156                return ProfeatProperties.getDistributionPosition(new ProteinSequence(sequence), attribute, group, distribution);
157        }
158
159        public static Map<DISTRIBUTION, Double> getDistributionPosition(String sequence, ATTRIBUTE attribute, GROUPING group) throws Exception{
160                return ProfeatProperties.getDistributionPosition(new ProteinSequence(sequence), attribute, group);
161        }
162
163        public static Map<GROUPING, Map<DISTRIBUTION, Double>> getDistributionPosition(String sequence, ATTRIBUTE attribute) throws Exception{
164                return ProfeatProperties.getDistributionPosition(new ProteinSequence(sequence), attribute);
165        }
166
167        public static Map<ATTRIBUTE , Map<GROUPING, Map<DISTRIBUTION, Double>>> getDistributionPosition(String sequence) throws Exception{
168                return ProfeatProperties.getDistributionPosition(new ProteinSequence(sequence));
169        }
170}