Merge branch 'feature/JAL-3187linkedFeatures' into feature/JAL-3251biotypedMappings
[jalview.git] / src / jalview / io / gff / GffHelperBase.java
index 301aaec..2206a03 100644 (file)
@@ -88,15 +88,15 @@ public abstract class GffHelperBase implements GffHelperI
     int[] to = new int[] { toStart, toEnd };
 
     /*
-     * Jalview always models from dna to protein, so switch values if the
-     * GFF mapping is from protein to dna
+     * Jalview always models from dna to protein, so invert 
+     * mapping if the GFF mapping is from protein to dna
      */
-    if (mappingType == MappingType.PeptideToNucleotide)
+    if (MappingType.isPeptideToDna(mappingType))
     {
       int[] temp = from;
       from = to;
       to = temp;
-      mappingType = mappingType.getInverse();
+      mappingType = MappingType.CdsToPeptide;
     }
 
     int fromRatio = mappingType.getFromRatio();
@@ -286,7 +286,7 @@ public abstract class GffHelperBase implements GffHelperI
           String namesDelimiter, char nameValueSeparator,
           String valuesDelimiter)
   {
-    Map<String, List<String>> map = new HashMap<String, List<String>>();
+    Map<String, List<String>> map = new HashMap<>();
     if (text == null || text.trim().length() == 0)
     {
       return map;
@@ -314,7 +314,7 @@ public abstract class GffHelperBase implements GffHelperI
         List<String> vals = map.get(key);
         if (vals == null)
         {
-          vals = new ArrayList<String>();
+          vals = new ArrayList<>();
           map.put(key, vals);
         }
         for (String val : values.split(valuesDelimiter))
@@ -338,6 +338,19 @@ public abstract class GffHelperBase implements GffHelperI
   protected SequenceFeature buildSequenceFeature(String[] gff,
           Map<String, List<String>> attributes)
   {
+    return buildSequenceFeature(gff, TYPE_COL, gff[SOURCE_COL], attributes);
+  }
+
+  /**
+   * @param gff
+   * @param typeColumn
+   * @param group
+   * @param attributes
+   * @return
+   */
+  protected SequenceFeature buildSequenceFeature(String[] gff,
+          int typeColumn, String group, Map<String, List<String>> attributes)
+  {
     try
     {
       int start = Integer.parseInt(gff[START_COL]);
@@ -356,8 +369,8 @@ public abstract class GffHelperBase implements GffHelperI
         // e.g. '.' - leave as zero
       }
 
-      SequenceFeature sf = new SequenceFeature(gff[TYPE_COL],
-              gff[SOURCE_COL], start, end, score, gff[SOURCE_COL]);
+      SequenceFeature sf = new SequenceFeature(gff[typeColumn],
+              gff[SOURCE_COL], start, end, score, group);
 
       sf.setStrand(gff[STRAND_COL]);