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 * @author Jacek Grzebyta <github:jgrzebyta> 015 * 016 * For more information on the BioJava project and its aims, 017 * or to join the biojava-l mailing list, visit the home page 018 * at: 019 * 020 * http://www.biojava.org/ 021 * 022 * Created on 25-07-2014 023 * 024 */ 025 026package org.biojava.nbio.core.sequence.features; 027 028import org.biojava.nbio.core.sequence.location.template.AbstractLocation; 029import org.biojava.nbio.core.sequence.template.AbstractSequence; 030import org.biojava.nbio.core.sequence.template.Compound; 031 032import java.util.ArrayList; 033import java.util.HashMap; 034import java.util.List; 035import java.util.Map; 036 037/** 038 * It is {@link DBReferenceInfo} which implements {@link FeatureInterface}. It allows to keep a dbReferenceInfo as a feature. 039 * 040 * @author Jacek Grzebyta 041 * @author Paolo Pavan 042 * @param <S> 043 * @param <C> 044 */ 045public class FeatureDbReferenceInfo<S extends AbstractSequence<C>, C extends Compound> extends DBReferenceInfo implements FeatureInterface<S,C> { 046 047 private AbstractLocation location; 048 private FeatureInterface<S,C> parentFeature; 049 private List<FeatureInterface<S, C>> childrenFeatures = new ArrayList<FeatureInterface<S, C>>(); 050 private String description = ""; 051 private String shortDescription = ""; 052 private Object userObject; 053 private Map<String, List<Qualifier>> qualifiers = new HashMap<String,List<Qualifier>>(); 054 055 056 public FeatureDbReferenceInfo(String database, String id) { 057 super(database, id); 058 } 059 060 @Override 061 public String getShortDescription() { 062 return shortDescription; 063 } 064 065 @Override 066 public void setShortDescription(String shortDescription) { 067 this.shortDescription = shortDescription; 068 } 069 070 @Override 071 public String getDescription() { 072 return description; 073 } 074 075 @Override 076 public void setDescription(String description) { 077 this.description = description; 078 } 079 080 @Override 081 public AbstractLocation getLocations() { 082 return location; 083 } 084 085 @Override 086 public void setLocation(AbstractLocation loc) { 087 location = loc; 088 } 089 090 @Override 091 public String getType() { 092 return super.getDatabase(); 093 } 094 095 @Override 096 public void setType(String type) { 097 super.setDatabase(type); 098 } 099 100 @Override 101 public String getSource() { 102 return super.getId(); 103 } 104 105 @Override 106 public void setSource(String source) { 107 super.setId(source); 108 } 109 110 @Override 111 public void setParentFeature(FeatureInterface<S,C> feature) { 112 this.parentFeature = feature; 113 } 114 115 @Override 116 public FeatureInterface<S,C> getParentFeature() { 117 return this.parentFeature; 118 } 119 120 @Override 121 public List<FeatureInterface<S, C>> getChildrenFeatures() { 122 return this.childrenFeatures; 123 } 124 125 @Override 126 public void setChildrenFeatures(List<FeatureInterface<S, C>> features) { 127 this.childrenFeatures = features; 128 } 129 130 @Override 131 public Object getUserObject() { 132 return this.userObject; 133 } 134 135 @Override 136 public void setUserObject(Object userObject) { 137 this.userObject = userObject; 138 } 139 140 @Override 141 public Map<String, List<Qualifier>> getQualifiers() { 142 return qualifiers; 143 } 144 145 @Override 146 public void setQualifiers(Map<String, List<Qualifier>> qualifiers) { 147 this.qualifiers = qualifiers; 148 } 149 150 @Override 151 public void addQualifier(String key, Qualifier qualifier) { 152 if (qualifiers == null) { 153 qualifiers = new HashMap<String, List<Qualifier>>(); 154 } 155 // Check for key. Update list of values 156 if (qualifiers.containsKey(key)){ 157 List<Qualifier> vals = qualifiers.get(key); 158 vals.add(qualifier); 159 qualifiers.put(key, vals); 160 } else { 161 List<Qualifier> vals = new ArrayList<Qualifier>(); 162 vals.add(qualifier); 163 qualifiers.put(key, vals); 164 } 165 166 } 167}