X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=a704f24d93fec206ccbb651e1640e53e0de3413a;hb=b19880049cdb11882e68c75d7960465be4aa8665;hp=169da5a5ae8624885d772814aa049ede2be2e4ac;hpb=252ddd218b716396b003b3fcbe0f8da499bde8c8;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 169da5a..a704f24 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -20,20 +20,35 @@ */ package jalview.io; +import java.awt.Color; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.TreeMap; + import jalview.analysis.AlignmentUtils; import jalview.analysis.SequenceIdMatcher; import jalview.api.AlignViewportI; import jalview.api.FeatureColourI; +import jalview.api.FeatureRenderer; import jalview.api.FeaturesSourceI; import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; +import jalview.datamodel.MappedFeatures; import jalview.datamodel.SequenceDummy; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.datamodel.features.FeatureMatcherSet; import jalview.datamodel.features.FeatureMatcherSetI; -import jalview.io.gff.GffHelperBase; +import jalview.gui.Desktop; import jalview.io.gff.GffHelperFactory; import jalview.io.gff.GffHelperI; import jalview.schemes.FeatureColour; @@ -42,16 +57,6 @@ import jalview.util.MapList; import jalview.util.ParseHtmlBodyAndLinks; import jalview.util.StringUtils; -import java.awt.Color; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - /** * Parses and writes features files, which may be in Jalview, GFF2 or GFF3 * format. These are tab-delimited formats but with differences in the use of @@ -70,6 +75,8 @@ import java.util.Map.Entry; */ public class FeaturesFile extends AlignFile implements FeaturesSourceI { + private static final String EQUALS = "="; + private static final String TAB_REGEX = "\\t"; private static final String STARTGROUP = "STARTGROUP"; @@ -82,8 +89,6 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED"; - private static final String NOTE = "Note"; - protected static final String GFF_VERSION = "##gff-version"; private AlignmentI lastmatchedAl = null; @@ -105,11 +110,11 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * Constructor which does not parse the file immediately * * @param file + * File or String filename * @param paste * @throws IOException */ - public FeaturesFile(String file, DataSourceType paste) - throws IOException + public FeaturesFile(Object file, DataSourceType paste) throws IOException { super(false, file, paste); } @@ -131,7 +136,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @param type * @throws IOException */ - public FeaturesFile(boolean parseImmediately, String file, + public FeaturesFile(boolean parseImmediately, Object file, DataSourceType type) throws IOException { super(parseImmediately, file, type); @@ -230,7 +235,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI // skip comments/process pragmas if (line.length() == 0 || line.startsWith("#")) { - if (line.toLowerCase().startsWith("##")) + if (line.toLowerCase(Locale.ROOT).startsWith("##")) { processGffPragma(line, gffProps, align, newseqs); } @@ -307,7 +312,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI // should report somewhere useful for UI if necessary warningMessage = ((warningMessage == null) ? "" : warningMessage) + "Parsing error at\n" + line; - System.out.println("Error parsing feature file: " + ex + "\n" + line); + jalview.bin.Console.outPrintln("Error parsing feature file: " + ex + "\n" + line); ex.printStackTrace(System.err); resetMatcher(); return false; @@ -342,14 +347,14 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI String line; while ((line = nextLine()) != null) { - if (line.toUpperCase().startsWith(ENDFILTERS)) + if (line.toUpperCase(Locale.ROOT).startsWith(ENDFILTERS)) { return; } String[] tokens = line.split(TAB_REGEX); if (tokens.length != 2) { - System.err.println(String.format("Invalid token count %d for %d", + jalview.bin.Console.errPrintln(String.format("Invalid token count %d for %d", tokens.length, line)); } else @@ -387,7 +392,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI */ if (gffColumns.length < 6) { - System.err.println("Ignoring feature line '" + line + jalview.bin.Console.errPrintln("Ignoring feature line '" + line + "' with too few columns (" + gffColumns.length + ")"); return false; } @@ -410,13 +415,13 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI seq = alignment.getSequenceAt(idx); } catch (NumberFormatException ex) { - System.err.println("Invalid sequence index: " + seqIndex); + jalview.bin.Console.errPrintln("Invalid sequence index: " + seqIndex); } } if (seq == null) { - System.out.println("Sequence not found: " + line); + jalview.bin.Console.outPrintln("Sequence not found: " + line); return false; } @@ -440,7 +445,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI float score = Float.NaN; try { - score = new Float(gffColumns[6]).floatValue(); + score = Float.valueOf(gffColumns[6]).floatValue(); } catch (NumberFormatException ex) { sf = new SequenceFeature(ft, desc, startPos, endPos, featureGroup); @@ -562,97 +567,206 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } /** - * Returns contents of a Jalview format features file, for visible features, as - * filtered by type and group. Features with a null group are displayed if their - * feature type is visible. Non-positional features may optionally be included - * (with no check on type or group). + * Returns contents of a Jalview format features file, for visible features, + * as filtered by type and group. Features with a null group are displayed if + * their feature type is visible. Non-positional features may optionally be + * included (with no check on type or group). * * @param sequences - * source of features - * @param visible - * map of colour for each visible feature type - * @param featureFilters - * @param visibleFeatureGroups + * @param fr * @param includeNonPositional * if true, include non-positional features (regardless of group or * type) + * @param includeComplement + * if true, include visible complementary (CDS/protein) positional + * features, with locations converted to local sequence coordinates * @return */ public String printJalviewFormat(SequenceI[] sequences, - Map visible, - Map featureFilters, - List visibleFeatureGroups, boolean includeNonPositional) + FeatureRenderer fr, boolean includeNonPositional, + boolean includeComplement) { - if (!includeNonPositional && (visible == null || visible.isEmpty())) - { - // no point continuing. - return "No Features Visible"; - } + Map visibleColours = fr + .getDisplayedFeatureCols(); + Map featureFilters = fr.getFeatureFilters(); /* * write out feature colours (if we know them) */ // TODO: decide if feature links should also be written here ? StringBuilder out = new StringBuilder(256); - if (visible != null) + if (visibleColours != null) { - for (Entry featureColour : visible.entrySet()) + for (Entry featureColour : visibleColours + .entrySet()) { FeatureColourI colour = featureColour.getValue(); - out.append(colour.toJalviewFormat(featureColour.getKey())).append( - newline); + out.append(colour.toJalviewFormat(featureColour.getKey())) + .append(newline); } } - String[] types = visible == null ? new String[0] : visible.keySet() - .toArray(new String[visible.keySet().size()]); + String[] types = visibleColours == null ? new String[0] + : visibleColours.keySet() + .toArray(new String[visibleColours.keySet().size()]); /* * feature filters if any */ - outputFeatureFilters(out, visible, featureFilters); + outputFeatureFilters(out, visibleColours, featureFilters); /* - * sort groups alphabetically, and ensure that features with a - * null or empty group are output after those in named groups + * output features within groups */ - List sortedGroups = new ArrayList<>(visibleFeatureGroups); - sortedGroups.remove(null); - sortedGroups.remove(""); - Collections.sort(sortedGroups); - sortedGroups.add(null); - sortedGroups.add(""); + int count = outputFeaturesByGroup(out, fr, types, sequences, + includeNonPositional); - boolean foundSome = false; + if (includeComplement) + { + count += outputComplementFeatures(out, fr, sequences); + } + + return count > 0 ? out.toString() : "No Features Visible"; + } + + /** + * Outputs any visible complementary (CDS/peptide) positional features as + * Jalview format, within feature group. The coordinates of the linked + * features are converted to the corresponding positions of the local + * sequences. + * + * @param out + * @param fr + * @param sequences + * @return + */ + private int outputComplementFeatures(StringBuilder out, + FeatureRenderer fr, SequenceI[] sequences) + { + AlignViewportI comp = fr.getViewport().getCodingComplement(); + FeatureRenderer fr2 = Desktop.getAlignFrameFor(comp) + .getFeatureRenderer(); /* - * first output any non-positional features + * bin features by feature group and sequence */ - if (includeNonPositional) + Map>> map = new TreeMap<>( + String.CASE_INSENSITIVE_ORDER); + int count = 0; + + for (SequenceI seq : sequences) { - for (int i = 0; i < sequences.length; i++) + /* + * find complementary features + */ + List complementary = findComplementaryFeatures(seq, + fr2); + String seqName = seq.getName(); + + for (SequenceFeature sf : complementary) { - String sequenceName = sequences[i].getName(); - for (SequenceFeature feature : sequences[i].getFeatures() - .getNonPositionalFeatures()) + String group = sf.getFeatureGroup(); + if (!map.containsKey(group)) + { + map.put(group, new LinkedHashMap<>()); // preserves sequence order + } + Map> groupFeatures = map.get(group); + if (!groupFeatures.containsKey(seqName)) { - foundSome = true; - out.append(formatJalviewFeature(sequenceName, feature)); + groupFeatures.put(seqName, new ArrayList<>()); } + List foundFeatures = groupFeatures.get(seqName); + foundFeatures.add(sf); + count++; } } /* - * positional features within groups + * output features by group */ - foundSome |= outputFeaturesByGroup(out, sortedGroups, types, sequences); + for (Entry>> groupFeatures : map + .entrySet()) + { + out.append(newline); + String group = groupFeatures.getKey(); + if (!"".equals(group)) + { + out.append(STARTGROUP).append(TAB).append(group).append(newline); + } + Map> seqFeaturesMap = groupFeatures + .getValue(); + for (Entry> seqFeatures : seqFeaturesMap + .entrySet()) + { + String sequenceName = seqFeatures.getKey(); + for (SequenceFeature sf : seqFeatures.getValue()) + { + formatJalviewFeature(out, sequenceName, sf); + } + } + if (!"".equals(group)) + { + out.append(ENDGROUP).append(TAB).append(group).append(newline); + } + } - return foundSome ? out.toString() : "No Features Visible"; + return count; } /** - * Outputs any feature filters defined for visible feature types, sandwiched by - * STARTFILTERS and ENDFILTERS lines + * Answers a list of mapped features visible in the (CDS/protein) complement, + * with feature positions translated to local sequence coordinates + * + * @param seq + * @param fr2 + * @return + */ + protected List findComplementaryFeatures(SequenceI seq, + FeatureRenderer fr2) + { + /* + * avoid duplication of features (e.g. peptide feature + * at all 3 mapped codon positions) + */ + List found = new ArrayList<>(); + List complementary = new ArrayList<>(); + + for (int pos = seq.getStart(); pos <= seq.getEnd(); pos++) + { + MappedFeatures mf = fr2.findComplementFeaturesAtResidue(seq, pos); + + if (mf != null) + { + for (SequenceFeature sf : mf.features) + { + /* + * make a virtual feature with local coordinates + */ + if (!found.contains(sf)) + { + String group = sf.getFeatureGroup(); + if (group == null) + { + group = ""; + } + found.add(sf); + int begin = sf.getBegin(); + int end = sf.getEnd(); + int[] range = mf.getMappedPositions(begin, end); + SequenceFeature sf2 = new SequenceFeature(sf, range[0], + range[1], group, sf.getScore()); + complementary.add(sf2); + } + } + } + } + + return complementary; + } + + /** + * Outputs any feature filters defined for visible feature types, sandwiched + * by STARTFILTERS and ENDFILTERS lines * * @param out * @param visible @@ -685,76 +799,116 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } if (!first) { - out.append(ENDFILTERS).append(newline).append(newline); + out.append(ENDFILTERS).append(newline); } } /** - * Appends output of sequence features within feature groups to the output - * buffer. Groups other than the null or empty group are sandwiched by - * STARTGROUP and ENDGROUP lines. + * Appends output of visible sequence features within feature groups to the + * output buffer. Groups other than the null or empty group are sandwiched by + * STARTGROUP and ENDGROUP lines. Answers the number of features written. * * @param out - * @param groups + * @param fr * @param featureTypes * @param sequences + * @param includeNonPositional * @return */ - private boolean outputFeaturesByGroup(StringBuilder out, - List groups, String[] featureTypes, SequenceI[] sequences) + private int outputFeaturesByGroup(StringBuilder out, FeatureRenderer fr, + String[] featureTypes, SequenceI[] sequences, + boolean includeNonPositional) { - boolean foundSome = false; - for (String group : groups) + List featureGroups = fr.getFeatureGroups(); + + /* + * sort groups alphabetically, and ensure that features with a + * null or empty group are output after those in named groups + */ + List sortedGroups = new ArrayList<>(featureGroups); + sortedGroups.remove(null); + sortedGroups.remove(""); + Collections.sort(sortedGroups); + sortedGroups.add(null); + sortedGroups.add(""); + + int count = 0; + List visibleGroups = fr.getDisplayedFeatureGroups(); + + /* + * loop over all groups (may be visible or not); + * non-positional features are output even if group is not visible + */ + for (String group : sortedGroups) { - boolean isNamedGroup = (group != null && !"".equals(group)); - if (isNamedGroup) - { - out.append(newline); - out.append(STARTGROUP).append(TAB); - out.append(group); - out.append(newline); - } + boolean firstInGroup = true; + boolean isNullGroup = group == null || "".equals(group); - /* - * output positional features within groups - */ for (int i = 0; i < sequences.length; i++) { String sequenceName = sequences[i].getName(); List features = new ArrayList<>(); - if (featureTypes.length > 0) + + /* + * get any non-positional features in this group, if wanted + * (for any feature type, whether visible or not) + */ + if (includeNonPositional) { - features.addAll(sequences[i].getFeatures().getFeaturesForGroup( - true, group, featureTypes)); + features.addAll(sequences[i].getFeatures() + .getFeaturesForGroup(false, group)); } - for (SequenceFeature sequenceFeature : features) + /* + * add positional features for visible feature types, but + * (for named groups) only if feature group is visible + */ + if (featureTypes.length > 0 + && (isNullGroup || visibleGroups.contains(group))) { - foundSome = true; - out.append(formatJalviewFeature(sequenceName, sequenceFeature)); + features.addAll(sequences[i].getFeatures() + .getFeaturesForGroup(true, group, featureTypes)); + } + + for (SequenceFeature sf : features) + { + if (sf.isNonPositional() || fr.isVisible(sf)) + { + count++; + if (firstInGroup) + { + out.append(newline); + if (!isNullGroup) + { + out.append(STARTGROUP).append(TAB).append(group) + .append(newline); + } + } + firstInGroup = false; + formatJalviewFeature(out, sequenceName, sf); + } } } - if (isNamedGroup) + if (!isNullGroup && !firstInGroup) { - out.append(ENDGROUP).append(TAB); - out.append(group); - out.append(newline); + out.append(ENDGROUP).append(TAB).append(group).append(newline); } } - return foundSome; + return count; } /** + * Formats one feature in Jalview format and appends to the string buffer + * * @param out * @param sequenceName * @param sequenceFeature */ - protected String formatJalviewFeature( + protected void formatJalviewFeature(StringBuilder out, String sequenceName, SequenceFeature sequenceFeature) { - StringBuilder out = new StringBuilder(64); if (sequenceFeature.description == null || sequenceFeature.description.equals("")) { @@ -779,7 +933,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI if (sequenceFeature.description.indexOf(href) == -1) { - out.append(" " + label + ""); + out.append(" ") + .append(label).append(""); } } @@ -804,8 +959,6 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI out.append(sequenceFeature.score); } out.append(newline); - - return out.toString(); } /** @@ -856,7 +1009,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI @Override public String print(SequenceI[] sqs, boolean jvsuffix) { - System.out.println("Use printGffFormat() or printJalviewFormat()"); + jalview.bin.Console.outPrintln("Use printGffFormat() or printJalviewFormat()"); return null; } @@ -869,81 +1022,66 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * a map whose keys are the type names of visible features * @param visibleFeatureGroups * @param includeNonPositionalFeatures + * @param includeComplement * @return */ - public String printGffFormat(SequenceI[] sequences, - Map visible, - List visibleFeatureGroups, - boolean includeNonPositionalFeatures) + public String printGffFormat(SequenceI[] sequences, FeatureRenderer fr, + boolean includeNonPositionalFeatures, boolean includeComplement) { - StringBuilder out = new StringBuilder(256); - - out.append(String.format("%s %d\n", GFF_VERSION, gffVersion == 0 ? 2 : gffVersion)); - - if (!includeNonPositionalFeatures - && (visible == null || visible.isEmpty())) + FeatureRenderer fr2 = null; + if (includeComplement) { - return out.toString(); + AlignViewportI comp = fr.getViewport().getCodingComplement(); + fr2 = Desktop.getAlignFrameFor(comp).getFeatureRenderer(); } - String[] types = visible == null ? new String[0] : visible.keySet() - .toArray( - new String[visible.keySet().size()]); + Map visibleColours = fr + .getDisplayedFeatureCols(); + + StringBuilder out = new StringBuilder(256); + + out.append(String.format("%s %d\n", GFF_VERSION, + gffVersion == 0 ? 2 : gffVersion)); + + String[] types = visibleColours == null ? new String[0] + : visibleColours.keySet() + .toArray(new String[visibleColours.keySet().size()]); for (SequenceI seq : sequences) { + List seqFeatures = new ArrayList<>(); List features = new ArrayList<>(); if (includeNonPositionalFeatures) { features.addAll(seq.getFeatures().getNonPositionalFeatures()); } - if (visible != null && !visible.isEmpty()) + if (visibleColours != null && !visibleColours.isEmpty()) { features.addAll(seq.getFeatures().getPositionalFeatures(types)); } - for (SequenceFeature sf : features) { - String source = sf.featureGroup; - if (!sf.isNonPositional() && source != null - && !visibleFeatureGroups.contains(source)) + if (sf.isNonPositional() || fr.isVisible(sf)) { - // group is not visible - continue; - } - - if (source == null) - { - source = sf.getDescription(); + /* + * drop features hidden by group visibility, colour threshold, + * or feature filter condition + */ + seqFeatures.add(sf); } + } - out.append(seq.getName()); - out.append(TAB); - out.append(source); - out.append(TAB); - out.append(sf.type); - out.append(TAB); - out.append(sf.begin); - out.append(TAB); - out.append(sf.end); - out.append(TAB); - out.append(sf.score); - out.append(TAB); - - int strand = sf.getStrand(); - out.append(strand == 1 ? "+" : (strand == -1 ? "-" : ".")); - out.append(TAB); - - String phase = sf.getPhase(); - out.append(phase == null ? "." : phase); - - // miscellaneous key-values (GFF column 9) - String attributes = sf.getAttributes(); - if (attributes != null) - { - out.append(TAB).append(attributes); - } + if (includeComplement) + { + seqFeatures.addAll(findComplementaryFeatures(seq, fr2)); + } + /* + * sort features here if wanted + */ + for (SequenceFeature sf : seqFeatures) + { + formatGffFeature(out, seq, sf); out.append(newline); } } @@ -952,6 +1090,145 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } /** + * Formats one feature as GFF and appends to the string buffer + */ + private void formatGffFeature(StringBuilder out, SequenceI seq, + SequenceFeature sf) + { + String source = sf.featureGroup; + if (source == null) + { + source = sf.getDescription(); + } + + out.append(seq.getName()); + out.append(TAB); + out.append(source); + out.append(TAB); + out.append(sf.type); + out.append(TAB); + out.append(sf.begin); + out.append(TAB); + out.append(sf.end); + out.append(TAB); + out.append(sf.score); + out.append(TAB); + + int strand = sf.getStrand(); + out.append(strand == 1 ? "+" : (strand == -1 ? "-" : ".")); + out.append(TAB); + + String phase = sf.getPhase(); + out.append(phase == null ? "." : phase); + + if (sf.otherDetails != null && !sf.otherDetails.isEmpty()) + { + Map map = sf.otherDetails; + formatAttributes(out, map); + } + } + + /** + * A helper method that outputs attributes stored in the map as + * semicolon-delimited values e.g. + * + *
+   * AC_Male=0;AF_NFE=0.00000e 00;Hom_FIN=0;GQ_MEDIAN=9
+   * 
+ * + * A map-valued attribute is formatted as a comma-delimited list within + * braces, for example + * + *
+   * jvmap_CSQ={ALLELE_NUM=1,UNIPARC=UPI0002841053,Feature=ENST00000585561}
+   * 
+ * + * The {@code jvmap_} prefix designates a values map and is removed if the + * value is parsed when read in. (The GFF3 specification allows + * 'semi-structured data' to be represented provided the attribute name begins + * with a lower case letter.) + * + * @param sb + * @param map + * @see http://gmod.org/wiki/GFF3#GFF3_Format + */ + void formatAttributes(StringBuilder sb, Map map) + { + sb.append(TAB); + boolean first = true; + for (String key : map.keySet()) + { + if (SequenceFeature.STRAND.equals(key) + || SequenceFeature.PHASE.equals(key)) + { + /* + * values stashed in map but output to their own columns + */ + continue; + } + { + if (!first) + { + sb.append(";"); + } + } + first = false; + Object value = map.get(key); + if (value instanceof Map) + { + formatMapAttribute(sb, key, (Map) value); + } + else + { + String formatted = StringUtils.urlEncode(value.toString(), + GffHelperI.GFF_ENCODABLE); + sb.append(key).append(EQUALS).append(formatted); + } + } + } + + /** + * Formats the map entries as + * + *
+   * key=key1=value1,key2=value2,...
+   * 
+ * + * and appends this to the string buffer + * + * @param sb + * @param key + * @param map + */ + private void formatMapAttribute(StringBuilder sb, String key, + Map map) + { + if (map == null || map.isEmpty()) + { + return; + } + + /* + * AbstractMap.toString would be a shortcut here, but more reliable + * to code the required format in case toString changes in future + */ + sb.append(key).append(EQUALS); + boolean first = true; + for (Entry entry : map.entrySet()) + { + if (!first) + { + sb.append(","); + } + first = false; + sb.append(entry.getKey().toString()).append(EQUALS); + String formatted = StringUtils.urlEncode(entry.getValue().toString(), + GffHelperI.GFF_ENCODABLE); + sb.append(formatted); + } + } + + /** * Returns a mapping given list of one or more Align descriptors (exonerate * format) * @@ -1056,7 +1333,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI */ if (gffColumns.length < 5) { - System.err.println("Ignoring GFF feature line with too few columns (" + jalview.bin.Console.errPrintln("Ignoring GFF feature line with too few columns (" + gffColumns.length + ")"); return null; } @@ -1087,7 +1364,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } } catch (IOException e) { - System.err.println("GFF parsing failed with: " + e.getMessage()); + jalview.bin.Console.errPrintln("GFF parsing failed with: " + e.getMessage()); return null; } } @@ -1096,38 +1373,6 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } /** - * Process the 'column 9' data of the GFF file. This is less formally defined, - * and its interpretation will vary depending on the tool that has generated - * it. - * - * @param attributes - * @param sf - */ - protected void processGffColumnNine(String attributes, SequenceFeature sf) - { - sf.setAttributes(attributes); - - /* - * Parse attributes in column 9 and add them to the sequence feature's - * 'otherData' table; use Note as a best proxy for description - */ - char nameValueSeparator = gffVersion == 3 ? '=' : ' '; - // TODO check we don't break GFF2 values which include commas here - Map> nameValues = GffHelperBase - .parseNameValuePairs(attributes, ";", nameValueSeparator, ","); - for (Entry> attr : nameValues.entrySet()) - { - String values = StringUtils.listToDelimitedString(attr.getValue(), - "; "); - sf.setValue(attr.getKey(), values); - if (NOTE.equals(attr.getKey())) - { - sf.setDescription(values); - } - } - } - - /** * After encountering ##fasta in a GFF3 file, process the remainder of the * file as FAST sequence data. Any placeholder sequences created during * feature parsing are updated with the actual sequences. @@ -1145,7 +1390,9 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } catch (IOException q) { } - FastaFile parser = new FastaFile(this); + // Opening a FastaFile object with the remainder of this object's dataIn. + // Tell the constructor to NOT close the dataIn when finished. + FastaFile parser = new FastaFile(this, false); List includedseqs = parser.getSeqs(); SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs); @@ -1208,8 +1455,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI List sfs = seq.getFeatures().getPositionalFeatures(); if (!sfs.isEmpty()) { - String newName = (String) sfs.get(0).getValue( - GffHelperI.RENAME_TOKEN); + String newName = (String) sfs.get(0) + .getValue(GffHelperI.RENAME_TOKEN); if (newName != null) { seq.setName(newName); @@ -1285,7 +1532,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI } else { - System.err.println("Ignoring unknown pragma: " + line); + jalview.bin.Console.errPrintln("Ignoring unknown pragma: " + line); } } }