Merge branch 'develop' into task/JAL-2196pdbeProperties
[jalview.git] / src / jalview / io / gff / Gff2Helper.java
1 package jalview.io.gff;
2
3 import jalview.datamodel.AlignmentI;
4 import jalview.datamodel.SequenceFeature;
5 import jalview.datamodel.SequenceI;
6
7 import java.io.IOException;
8 import java.util.List;
9 import java.util.Map;
10
11 public class Gff2Helper extends GffHelperBase
12 {
13   /**
14    * GFF2 uses space character to delimit name/value pairs on column 9
15    * 
16    * @param text
17    * @return
18    */
19   public static Map<String, List<String>> parseNameValuePairs(String text)
20   {
21     // TODO: can a value include a comma? if so it will be broken by this
22     return parseNameValuePairs(text, ";", ' ', ",");
23   }
24
25   /**
26    * Return ' ' as the name-value separator used in column 9 attributes.
27    */
28   @Override
29   protected char getNameValueSeparator()
30   {
31     return ' ';
32   }
33
34   /**
35    * Default processing if not overridden is just to construct a sequence
36    * feature
37    */
38   @Override
39   public SequenceFeature processGff(SequenceI seq, String[] gff,
40           AlignmentI align, List<SequenceI> newseqs,
41           boolean relaxedIdMatching) throws IOException
42   {
43     Map<String, List<String>> attributes = null;
44     if (gff.length > ATTRIBUTES_COL)
45     {
46       attributes = parseNameValuePairs(gff[ATTRIBUTES_COL]);
47     }
48     return buildSequenceFeature(gff, attributes);
49   }
50
51 }