2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AlignmentUtils;
24 import jalview.analysis.SequenceIdMatcher;
25 import jalview.api.AlignViewportI;
26 import jalview.api.FeatureColourI;
27 import jalview.api.FeaturesSourceI;
28 import jalview.datamodel.AlignedCodonFrame;
29 import jalview.datamodel.Alignment;
30 import jalview.datamodel.AlignmentI;
31 import jalview.datamodel.SequenceDummy;
32 import jalview.datamodel.SequenceFeature;
33 import jalview.datamodel.SequenceI;
34 import jalview.io.gff.GffHelperBase;
35 import jalview.io.gff.GffHelperFactory;
36 import jalview.io.gff.GffHelperI;
37 import jalview.schemes.FeatureColour;
38 import jalview.schemes.UserColourScheme;
39 import jalview.util.MapList;
40 import jalview.util.ParseHtmlBodyAndLinks;
41 import jalview.util.StringUtils;
43 import java.io.IOException;
44 import java.util.ArrayList;
45 import java.util.Arrays;
46 import java.util.HashMap;
47 import java.util.Iterator;
48 import java.util.List;
50 import java.util.Map.Entry;
53 * Parses and writes features files, which may be in Jalview, GFF2 or GFF3
54 * format. These are tab-delimited formats but with differences in the use of
57 * A Jalview feature file may define feature colours and then declare that the
58 * remainder of the file is in GFF format with the line 'GFF'.
60 * GFF3 files may include alignment mappings for features, which Jalview will
61 * attempt to model, and may include sequence data following a ##FASTA line.
68 public class FeaturesFile extends AlignFile implements FeaturesSourceI
70 private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED";
72 private static final String NOTE = "Note";
74 protected static final String TAB = "\t";
76 protected static final String GFF_VERSION = "##gff-version";
78 private AlignmentI lastmatchedAl = null;
80 private SequenceIdMatcher matcher = null;
82 protected AlignmentI dataset;
84 protected int gffVersion;
87 * Creates a new FeaturesFile object.
94 * Constructor which does not parse the file immediately
100 public FeaturesFile(String inFile, DataSourceType paste)
103 super(false, inFile, paste);
108 * @throws IOException
110 public FeaturesFile(FileParse source) throws IOException
116 * Constructor that optionally parses the file immediately
118 * @param parseImmediately
121 * @throws IOException
123 public FeaturesFile(boolean parseImmediately, String inFile,
127 super(parseImmediately, inFile, type);
131 * Parse GFF or sequence features file using case-independent matching,
135 * - alignment/dataset containing sequences that are to be annotated
137 * - hashtable to store feature colour definitions
139 * - process html strings into plain text
140 * @return true if features were added
142 public boolean parse(AlignmentI align,
143 Map<String, FeatureColourI> colours,
146 return parse(align, colours, removeHTML, false);
150 * Extends the default addProperties by also adding peptide-to-cDNA mappings
151 * (if any) derived while parsing a GFF file
154 public void addProperties(AlignmentI al)
156 super.addProperties(al);
157 if (dataset != null && dataset.getCodonFrames() != null)
159 AlignmentI ds = (al.getDataset() == null) ? al : al.getDataset();
160 for (AlignedCodonFrame codons : dataset.getCodonFrames())
162 ds.addCodonFrame(codons);
168 * Parse GFF or Jalview format sequence features file
171 * - alignment/dataset containing sequences that are to be annotated
173 * - hashtable to store feature colour definitions
175 * - process html strings into plain text
176 * @param relaxedIdmatching
177 * - when true, ID matches to compound sequence IDs are allowed
178 * @return true if features were added
180 public boolean parse(AlignmentI align,
181 Map<String, FeatureColourI> colours,
182 boolean removeHTML, boolean relaxedIdmatching)
184 Map<String, String> gffProps = new HashMap<String, String>();
186 * keep track of any sequences we try to create from the data
188 List<SequenceI> newseqs = new ArrayList<SequenceI>();
194 String featureGroup = null;
196 while ((line = nextLine()) != null)
198 // skip comments/process pragmas
199 if (line.length() == 0 || line.startsWith("#"))
201 if (line.toLowerCase().startsWith("##"))
203 processGffPragma(line, gffProps, align, newseqs);
208 gffColumns = line.split("\\t"); // tab as regex
209 if (gffColumns.length == 1)
211 if (line.trim().equalsIgnoreCase("GFF"))
214 * Jalview features file with appended GFF
215 * assume GFF2 (though it may declare ##gff-version 3)
222 if (gffColumns.length > 1 && gffColumns.length < 4)
225 * if 2 or 3 tokens, we anticipate either 'startgroup', 'endgroup' or
226 * a feature type colour specification
228 String ft = gffColumns[0];
229 if (ft.equalsIgnoreCase("startgroup"))
231 featureGroup = gffColumns[1];
233 else if (ft.equalsIgnoreCase("endgroup"))
235 // We should check whether this is the current group,
236 // but at present there's no way of showing more than 1 group
241 String colscheme = gffColumns[1];
242 FeatureColourI colour = FeatureColour
243 .parseJalviewFeatureColour(colscheme);
246 colours.put(ft, colour);
253 * if not a comment, GFF pragma, startgroup, endgroup or feature
254 * colour specification, that just leaves a feature details line
255 * in either Jalview or GFF format
259 parseJalviewFeature(line, gffColumns, align, colours, removeHTML,
260 relaxedIdmatching, featureGroup);
264 parseGff(gffColumns, align, relaxedIdmatching, newseqs);
268 } catch (Exception ex)
270 // should report somewhere useful for UI if necessary
271 warningMessage = ((warningMessage == null) ? "" : warningMessage)
272 + "Parsing error at\n" + line;
273 System.out.println("Error parsing feature file: " + ex + "\n" + line);
274 ex.printStackTrace(System.err);
280 * experimental - add any dummy sequences with features to the alignment
281 * - we need them for Ensembl feature extraction - though maybe not otherwise
283 for (SequenceI newseq : newseqs)
285 if (newseq.getSequenceFeatures() != null)
287 align.addSequence(newseq);
294 * Try to parse a Jalview format feature specification and add it as a
295 * sequence feature to any matching sequences in the alignment. Returns true
296 * if successful (a feature was added), or false if not.
301 * @param featureColours
303 * @param relaxedIdmatching
304 * @param featureGroup
306 protected boolean parseJalviewFeature(String line, String[] gffColumns,
307 AlignmentI alignment, Map<String, FeatureColourI> featureColours,
308 boolean removeHTML, boolean relaxedIdMatching, String featureGroup)
311 * tokens: description seqid seqIndex start end type [score]
313 if (gffColumns.length < 6)
315 System.err.println("Ignoring feature line '" + line
316 + "' with too few columns (" + gffColumns.length + ")");
319 String desc = gffColumns[0];
320 String seqId = gffColumns[1];
321 SequenceI seq = findSequence(seqId, alignment, null, relaxedIdMatching);
323 if (!ID_NOT_SPECIFIED.equals(seqId))
325 seq = findSequence(seqId, alignment, null, relaxedIdMatching);
331 String seqIndex = gffColumns[2];
334 int idx = Integer.parseInt(seqIndex);
335 seq = alignment.getSequenceAt(idx);
336 } catch (NumberFormatException ex)
338 System.err.println("Invalid sequence index: " + seqIndex);
344 System.out.println("Sequence not found: " + line);
348 int startPos = Integer.parseInt(gffColumns[3]);
349 int endPos = Integer.parseInt(gffColumns[4]);
351 String ft = gffColumns[5];
353 if (!featureColours.containsKey(ft))
356 * Perhaps an old style groups file with no colours -
357 * synthesize a colour from the feature type
359 UserColourScheme ucs = new UserColourScheme(ft);
360 featureColours.put(ft, new FeatureColour(ucs.findColour('A')));
362 SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos,
363 endPos, featureGroup);
364 if (gffColumns.length > 6)
366 float score = Float.NaN;
369 score = new Float(gffColumns[6]).floatValue();
370 // update colourgradient bounds if allowed to
371 } catch (NumberFormatException ex)
378 parseDescriptionHTML(sf, removeHTML);
380 seq.addSequenceFeature(sf);
383 && (seq = alignment.findName(seq, seqId, false)) != null)
385 seq.addSequenceFeature(new SequenceFeature(sf));
391 * clear any temporary handles used to speed up ID matching
393 protected void resetMatcher()
395 lastmatchedAl = null;
400 * Returns a sequence matching the given id, as follows
402 * <li>strict matching is on exact sequence name</li>
403 * <li>relaxed matching allows matching on a token within the sequence name,
405 * <li>first tries to find a match in the alignment sequences</li>
406 * <li>else tries to find a match in the new sequences already generated while
407 * parsing the features file</li>
408 * <li>else creates a new placeholder sequence, adds it to the new sequences
409 * list, and returns it</li>
415 * @param relaxedIdMatching
419 protected SequenceI findSequence(String seqId, AlignmentI align,
420 List<SequenceI> newseqs, boolean relaxedIdMatching)
422 // TODO encapsulate in SequenceIdMatcher, share the matcher
423 // with the GffHelper (removing code duplication)
424 SequenceI match = null;
425 if (relaxedIdMatching)
427 if (lastmatchedAl != align)
429 lastmatchedAl = align;
430 matcher = new SequenceIdMatcher(align.getSequencesArray());
433 matcher.addAll(newseqs);
436 match = matcher.findIdMatch(seqId);
440 match = align.findName(seqId, true);
441 if (match == null && newseqs != null)
443 for (SequenceI m : newseqs)
445 if (seqId.equals(m.getName()))
453 if (match == null && newseqs != null)
455 match = new SequenceDummy(seqId);
456 if (relaxedIdMatching)
458 matcher.addAll(Arrays.asList(new SequenceI[] { match }));
460 // add dummy sequence to the newseqs list
466 public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)
468 if (sf.getDescription() == null)
472 ParseHtmlBodyAndLinks parsed = new ParseHtmlBodyAndLinks(
473 sf.getDescription(), removeHTML, newline);
475 sf.description = (removeHTML) ? parsed.getNonHtmlContent()
477 for (String link : parsed.getLinks())
485 * generate a features file for seqs includes non-pos features by default.
488 * source of sequence features
490 * hash of feature types and colours
491 * @return features file contents
493 public String printJalviewFormat(SequenceI[] sequences,
494 Map<String, FeatureColourI> visible)
496 return printJalviewFormat(sequences, visible, true, true);
500 * generate a features file for seqs with colours from visible (if any)
505 * hash of Colours for each feature type
507 * when true only feature types in 'visible' will be output
509 * indicates if non-positional features should be output (regardless
511 * @return features file contents
513 public String printJalviewFormat(SequenceI[] sequences,
514 Map<String, FeatureColourI> visible, boolean visOnly,
517 StringBuilder out = new StringBuilder(256);
518 boolean featuresGen = false;
519 if (visOnly && !nonpos && (visible == null || visible.size() < 1))
521 // no point continuing.
522 return "No Features Visible";
525 if (visible != null && visOnly)
527 // write feature colours only if we're given them and we are generating
529 // TODO: decide if feature links should also be written here ?
530 Iterator<String> en = visible.keySet().iterator();
533 String featureType = en.next().toString();
534 FeatureColourI colour = visible.get(featureType);
535 out.append(colour.toJalviewFormat(featureType)).append(newline);
539 // Work out which groups are both present and visible
540 List<String> groups = new ArrayList<String>();
542 boolean isnonpos = false;
544 SequenceFeature[] features;
545 for (int i = 0; i < sequences.length; i++)
547 features = sequences[i].getSequenceFeatures();
548 if (features != null)
550 for (int j = 0; j < features.length; j++)
552 isnonpos = features[j].begin == 0 && features[j].end == 0;
553 if ((!nonpos && isnonpos)
554 || (!isnonpos && visOnly && !visible
555 .containsKey(features[j].type)))
560 if (features[j].featureGroup != null
561 && !groups.contains(features[j].featureGroup))
563 groups.add(features[j].featureGroup);
572 if (groups.size() > 0 && groupIndex < groups.size())
574 group = groups.get(groupIndex);
576 out.append("STARTGROUP").append(TAB);
585 for (int i = 0; i < sequences.length; i++)
587 features = sequences[i].getSequenceFeatures();
588 if (features != null)
590 for (SequenceFeature sequenceFeature : features)
592 isnonpos = sequenceFeature.begin == 0 && sequenceFeature.end == 0;
593 if ((!nonpos && isnonpos)
594 || (!isnonpos && visOnly && !visible
595 .containsKey(sequenceFeature.type)))
597 // skip if feature is nonpos and we ignore them or if we only
598 // output visible and it isn't non-pos and it's not visible
603 && (sequenceFeature.featureGroup == null || !sequenceFeature.featureGroup
609 if (group == null && sequenceFeature.featureGroup != null)
613 // we have features to output
615 if (sequenceFeature.description == null
616 || sequenceFeature.description.equals(""))
618 out.append(sequenceFeature.type).append(TAB);
622 if (sequenceFeature.links != null
623 && sequenceFeature.getDescription().indexOf("<html>") == -1)
625 out.append("<html>");
628 out.append(sequenceFeature.description);
629 if (sequenceFeature.links != null)
631 for (int l = 0; l < sequenceFeature.links.size(); l++)
633 String label = sequenceFeature.links.elementAt(l);
634 String href = label.substring(label.indexOf("|") + 1);
635 label = label.substring(0, label.indexOf("|"));
637 if (sequenceFeature.description.indexOf(href) == -1)
639 out.append(" <a href=\"" + href + "\">" + label
644 if (sequenceFeature.getDescription().indexOf("</html>") == -1)
646 out.append("</html>");
652 out.append(sequences[i].getName());
653 out.append("\t-1\t");
654 out.append(sequenceFeature.begin);
656 out.append(sequenceFeature.end);
658 out.append(sequenceFeature.type);
659 if (!Float.isNaN(sequenceFeature.score))
662 out.append(sequenceFeature.score);
671 out.append("ENDGROUP").append(TAB);
681 } while (groupIndex < groups.size() + 1);
685 return "No Features Visible";
688 return out.toString();
692 * Parse method that is called when a GFF file is dragged to the desktop
697 AlignViewportI av = getViewport();
700 if (av.getAlignment() != null)
702 dataset = av.getAlignment().getDataset();
706 // working in the applet context ?
707 dataset = av.getAlignment();
712 dataset = new Alignment(new SequenceI[] {});
715 boolean parseResult = parse(dataset, null, false, true);
718 // pass error up somehow
722 // update viewport with the dataset data ?
726 setSeqs(dataset.getSequencesArray());
731 * Implementation of unused abstract method
733 * @return error message
736 public String print()
738 return "Use printGffFormat() or printJalviewFormat()";
742 * Returns features output in GFF2 format, including hidden and non-positional
746 * the sequences whose features are to be output
748 * a map whose keys are the type names of visible features
751 public String printGffFormat(SequenceI[] sequences,
752 Map<String, FeatureColourI> visible)
754 return printGffFormat(sequences, visible, true, true);
758 * Returns features output in GFF2 format
761 * the sequences whose features are to be output
763 * a map whose keys are the type names of visible features
764 * @param outputVisibleOnly
765 * @param includeNonPositionalFeatures
768 public String printGffFormat(SequenceI[] sequences,
769 Map<String, FeatureColourI> visible, boolean outputVisibleOnly,
770 boolean includeNonPositionalFeatures)
772 StringBuilder out = new StringBuilder(256);
773 int version = gffVersion == 0 ? 2 : gffVersion;
774 out.append(String.format("%s %d\n", GFF_VERSION, version));
777 for (SequenceI seq : sequences)
779 SequenceFeature[] features = seq.getSequenceFeatures();
780 if (features != null)
782 for (SequenceFeature sf : features)
784 isnonpos = sf.begin == 0 && sf.end == 0;
785 if (!includeNonPositionalFeatures && isnonpos)
788 * ignore non-positional features if not wanted
792 // TODO why the test !isnonpos here?
793 // what about not visible non-positional features?
794 if (!isnonpos && outputVisibleOnly
795 && !visible.containsKey(sf.type))
798 * ignore not visible features if not wanted
803 source = sf.featureGroup;
806 source = sf.getDescription();
809 out.append(seq.getName());
815 out.append(sf.begin);
819 out.append(sf.score);
822 int strand = sf.getStrand();
823 out.append(strand == 1 ? "+" : (strand == -1 ? "-" : "."));
826 String phase = sf.getPhase();
827 out.append(phase == null ? "." : phase);
829 // miscellaneous key-values (GFF column 9)
830 String attributes = sf.getAttributes();
831 if (attributes != null)
833 out.append(TAB).append(attributes);
841 return out.toString();
845 * Returns a mapping given list of one or more Align descriptors (exonerate
848 * @param alignedRegions
849 * a list of "Align fromStart toStart fromCount"
850 * @param mapIsFromCdna
851 * if true, 'from' is dna, else 'from' is protein
853 * either 1 (forward) or -1 (reverse)
855 * @throws IOException
857 protected MapList constructCodonMappingFromAlign(
858 List<String> alignedRegions, boolean mapIsFromCdna, int strand)
863 throw new IOException(
864 "Invalid strand for a codon mapping (cannot be 0)");
866 int regions = alignedRegions.size();
867 // arrays to hold [start, end] for each aligned region
868 int[] fromRanges = new int[regions * 2]; // from dna
869 int[] toRanges = new int[regions * 2]; // to protein
870 int fromRangesIndex = 0;
871 int toRangesIndex = 0;
873 for (String range : alignedRegions)
876 * Align mapFromStart mapToStart mapFromCount
877 * e.g. if mapIsFromCdna
878 * Align 11270 143 120
880 * 120 bases from pos 11270 align to pos 143 in peptide
881 * if !mapIsFromCdna this would instead be
884 String[] tokens = range.split(" ");
885 if (tokens.length != 3)
887 throw new IOException("Wrong number of fields for Align");
894 fromStart = Integer.parseInt(tokens[0]);
895 toStart = Integer.parseInt(tokens[1]);
896 fromCount = Integer.parseInt(tokens[2]);
897 } catch (NumberFormatException nfe)
899 throw new IOException("Invalid number in Align field: "
904 * Jalview always models from dna to protein, so adjust values if the
905 * GFF mapping is from protein to dna
910 int temp = fromStart;
914 fromRanges[fromRangesIndex++] = fromStart;
915 fromRanges[fromRangesIndex++] = fromStart + strand * (fromCount - 1);
918 * If a codon has an intron gap, there will be contiguous 'toRanges';
919 * this is handled for us by the MapList constructor.
920 * (It is not clear that exonerate ever generates this case)
922 toRanges[toRangesIndex++] = toStart;
923 toRanges[toRangesIndex++] = toStart + (fromCount - 1) / 3;
926 return new MapList(fromRanges, toRanges, 3, 1);
930 * Parse a GFF format feature. This may include creating a 'dummy' sequence to
931 * hold the feature, or for its mapped sequence, or both, to be resolved
932 * either later in the GFF file (##FASTA section), or when the user loads
933 * additional sequences.
937 * @param relaxedIdMatching
941 protected SequenceI parseGff(String[] gffColumns, AlignmentI alignment,
942 boolean relaxedIdMatching, List<SequenceI> newseqs)
945 * GFF: seqid source type start end score strand phase [attributes]
947 if (gffColumns.length < 5)
949 System.err.println("Ignoring GFF feature line with too few columns ("
950 + gffColumns.length + ")");
955 * locate referenced sequence in alignment _or_
956 * as a forward or external reference (SequenceDummy)
958 String seqId = gffColumns[0];
959 SequenceI seq = findSequence(seqId, alignment, newseqs,
962 SequenceFeature sf = null;
963 GffHelperI helper = GffHelperFactory.getHelper(gffColumns);
968 sf = helper.processGff(seq, gffColumns, alignment, newseqs,
972 seq.addSequenceFeature(sf);
973 while ((seq = alignment.findName(seq, seqId, true)) != null)
975 seq.addSequenceFeature(new SequenceFeature(sf));
978 } catch (IOException e)
980 System.err.println("GFF parsing failed with: " + e.getMessage());
989 * Process the 'column 9' data of the GFF file. This is less formally defined,
990 * and its interpretation will vary depending on the tool that has generated
996 protected void processGffColumnNine(String attributes, SequenceFeature sf)
998 sf.setAttributes(attributes);
1001 * Parse attributes in column 9 and add them to the sequence feature's
1002 * 'otherData' table; use Note as a best proxy for description
1004 char nameValueSeparator = gffVersion == 3 ? '=' : ' ';
1005 // TODO check we don't break GFF2 values which include commas here
1006 Map<String, List<String>> nameValues = GffHelperBase
1007 .parseNameValuePairs(attributes, ";", nameValueSeparator, ",");
1008 for (Entry<String, List<String>> attr : nameValues.entrySet())
1010 String values = StringUtils.listToDelimitedString(attr.getValue(),
1012 sf.setValue(attr.getKey(), values);
1013 if (NOTE.equals(attr.getKey()))
1015 sf.setDescription(values);
1021 * After encountering ##fasta in a GFF3 file, process the remainder of the
1022 * file as FAST sequence data. Any placeholder sequences created during
1023 * feature parsing are updated with the actual sequences.
1027 * @throws IOException
1029 protected void processAsFasta(AlignmentI align, List<SequenceI> newseqs)
1035 } catch (IOException q)
1038 FastaFile parser = new FastaFile(this);
1039 List<SequenceI> includedseqs = parser.getSeqs();
1041 SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs);
1044 * iterate over includedseqs, and replacing matching ones with newseqs
1045 * sequences. Generic iterator not used here because we modify
1046 * includedseqs as we go
1048 for (int p = 0, pSize = includedseqs.size(); p < pSize; p++)
1050 // search for any dummy seqs that this sequence can be used to update
1051 SequenceI includedSeq = includedseqs.get(p);
1052 SequenceI dummyseq = smatcher.findIdMatch(includedSeq);
1053 if (dummyseq != null && dummyseq instanceof SequenceDummy)
1055 // probably have the pattern wrong
1056 // idea is that a flyweight proxy for a sequence ID can be created for
1057 // 1. stable reference creation
1058 // 2. addition of annotation
1059 // 3. future replacement by a real sequence
1060 // current pattern is to create SequenceDummy objects - a convenience
1061 // constructor for a Sequence.
1062 // problem is that when promoted to a real sequence, all references
1063 // need to be updated somehow. We avoid that by keeping the same object.
1064 ((SequenceDummy) dummyseq).become(includedSeq);
1065 dummyseq.createDatasetSequence();
1068 * Update mappings so they are now to the dataset sequence
1070 for (AlignedCodonFrame mapping : align.getCodonFrames())
1072 mapping.updateToDataset(dummyseq);
1076 * replace parsed sequence with the realised forward reference
1078 includedseqs.set(p, dummyseq);
1081 * and remove from the newseqs list
1083 newseqs.remove(dummyseq);
1088 * finally add sequences to the dataset
1090 for (SequenceI seq : includedseqs)
1092 // experimental: mapping-based 'alignment' to query sequence
1093 AlignmentUtils.alignSequenceAs(seq, align,
1094 String.valueOf(align.getGapCharacter()), false, true);
1096 // rename sequences if GFF handler requested this
1097 // TODO a more elegant way e.g. gffHelper.postProcess(newseqs) ?
1098 SequenceFeature[] sfs = seq.getSequenceFeatures();
1101 String newName = (String) sfs[0].getValue(GffHelperI.RENAME_TOKEN);
1102 if (newName != null)
1104 seq.setName(newName);
1107 align.addSequence(seq);
1112 * Process a ## directive
1118 * @throws IOException
1120 protected void processGffPragma(String line,
1121 Map<String, String> gffProps, AlignmentI align,
1122 List<SequenceI> newseqs) throws IOException
1125 if ("###".equals(line))
1127 // close off any open 'forward references'
1131 String[] tokens = line.substring(2).split(" ");
1132 String pragma = tokens[0];
1133 String value = tokens.length == 1 ? null : tokens[1];
1135 if ("gff-version".equalsIgnoreCase(pragma))
1141 // value may be e.g. "3.1.2"
1142 gffVersion = Integer.parseInt(value.split("\\.")[0]);
1143 } catch (NumberFormatException e)
1149 else if ("sequence-region".equalsIgnoreCase(pragma))
1151 // could capture <seqid start end> if wanted here
1153 else if ("feature-ontology".equalsIgnoreCase(pragma))
1155 // should resolve against the specified feature ontology URI
1157 else if ("attribute-ontology".equalsIgnoreCase(pragma))
1159 // URI of attribute ontology - not currently used in GFF3
1161 else if ("source-ontology".equalsIgnoreCase(pragma))
1163 // URI of source ontology - not currently used in GFF3
1165 else if ("species-build".equalsIgnoreCase(pragma))
1167 // save URI of specific NCBI taxon version of annotations
1168 gffProps.put("species-build", value);
1170 else if ("fasta".equalsIgnoreCase(pragma))
1172 // process the rest of the file as a fasta file and replace any dummy
1174 processAsFasta(align, newseqs);
1178 System.err.println("Ignoring unknown pragma: " + line);