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.util.ColorUtils;
39 import jalview.util.MapList;
40 import jalview.util.ParseHtmlBodyAndLinks;
41 import jalview.util.StringUtils;
43 import java.awt.Color;
44 import java.io.IOException;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.Collections;
48 import java.util.Comparator;
49 import java.util.HashMap;
50 import java.util.List;
52 import java.util.Map.Entry;
55 * Parses and writes features files, which may be in Jalview, GFF2 or GFF3
56 * format. These are tab-delimited formats but with differences in the use of
59 * A Jalview feature file may define feature colours and then declare that the
60 * remainder of the file is in GFF format with the line 'GFF'.
62 * GFF3 files may include alignment mappings for features, which Jalview will
63 * attempt to model, and may include sequence data following a ##FASTA line.
70 public class FeaturesFile extends AlignFile implements FeaturesSourceI
72 private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED";
74 private static final String NOTE = "Note";
76 protected static final String TAB = "\t";
78 protected static final String GFF_VERSION = "##gff-version";
80 private static final Comparator<String> SORT_NULL_LAST = new Comparator<String>()
83 public int compare(String o1, String o2)
87 return o2 == null ? 0 : 1;
89 return (o2 == null ? -1 : o1.compareTo(o2));
93 private AlignmentI lastmatchedAl = null;
95 private SequenceIdMatcher matcher = null;
97 protected AlignmentI dataset;
99 protected int gffVersion;
102 * Creates a new FeaturesFile object.
104 public FeaturesFile()
109 * Constructor which does not parse the file immediately
113 * @throws IOException
115 public FeaturesFile(String inFile, DataSourceType paste)
118 super(false, inFile, paste);
123 * @throws IOException
125 public FeaturesFile(FileParse source) throws IOException
131 * Constructor that optionally parses the file immediately
133 * @param parseImmediately
136 * @throws IOException
138 public FeaturesFile(boolean parseImmediately, String inFile,
142 super(parseImmediately, inFile, type);
146 * Parse GFF or sequence features file using case-independent matching,
150 * - alignment/dataset containing sequences that are to be annotated
152 * - hashtable to store feature colour definitions
154 * - process html strings into plain text
155 * @return true if features were added
157 public boolean parse(AlignmentI align,
158 Map<String, FeatureColourI> colours, boolean removeHTML)
160 return parse(align, colours, removeHTML, false);
164 * Extends the default addProperties by also adding peptide-to-cDNA mappings
165 * (if any) derived while parsing a GFF file
168 public void addProperties(AlignmentI al)
170 super.addProperties(al);
171 if (dataset != null && dataset.getCodonFrames() != null)
173 AlignmentI ds = (al.getDataset() == null) ? al : al.getDataset();
174 for (AlignedCodonFrame codons : dataset.getCodonFrames())
176 ds.addCodonFrame(codons);
182 * Parse GFF or Jalview format sequence features file
185 * - alignment/dataset containing sequences that are to be annotated
187 * - hashtable to store feature colour definitions
189 * - process html strings into plain text
190 * @param relaxedIdmatching
191 * - when true, ID matches to compound sequence IDs are allowed
192 * @return true if features were added
194 public boolean parse(AlignmentI align,
195 Map<String, FeatureColourI> colours, boolean removeHTML,
196 boolean relaxedIdmatching)
198 Map<String, String> gffProps = new HashMap<String, String>();
200 * keep track of any sequences we try to create from the data
202 List<SequenceI> newseqs = new ArrayList<SequenceI>();
208 String featureGroup = null;
210 while ((line = nextLine()) != null)
212 // skip comments/process pragmas
213 if (line.length() == 0 || line.startsWith("#"))
215 if (line.toLowerCase().startsWith("##"))
217 processGffPragma(line, gffProps, align, newseqs);
222 gffColumns = line.split("\\t"); // tab as regex
223 if (gffColumns.length == 1)
225 if (line.trim().equalsIgnoreCase("GFF"))
228 * Jalview features file with appended GFF
229 * assume GFF2 (though it may declare ##gff-version 3)
236 if (gffColumns.length > 1 && gffColumns.length < 4)
239 * if 2 or 3 tokens, we anticipate either 'startgroup', 'endgroup' or
240 * a feature type colour specification
242 String ft = gffColumns[0];
243 if (ft.equalsIgnoreCase("startgroup"))
245 featureGroup = gffColumns[1];
247 else if (ft.equalsIgnoreCase("endgroup"))
249 // We should check whether this is the current group,
250 // but at present there's no way of showing more than 1 group
255 String colscheme = gffColumns[1];
256 FeatureColourI colour = FeatureColour
257 .parseJalviewFeatureColour(colscheme);
260 colours.put(ft, colour);
267 * if not a comment, GFF pragma, startgroup, endgroup or feature
268 * colour specification, that just leaves a feature details line
269 * in either Jalview or GFF format
273 parseJalviewFeature(line, gffColumns, align, colours, removeHTML,
274 relaxedIdmatching, featureGroup);
278 parseGff(gffColumns, align, relaxedIdmatching, newseqs);
282 } catch (Exception ex)
284 // should report somewhere useful for UI if necessary
285 warningMessage = ((warningMessage == null) ? "" : warningMessage)
286 + "Parsing error at\n" + line;
287 System.out.println("Error parsing feature file: " + ex + "\n" + line);
288 ex.printStackTrace(System.err);
294 * experimental - add any dummy sequences with features to the alignment
295 * - we need them for Ensembl feature extraction - though maybe not otherwise
297 for (SequenceI newseq : newseqs)
299 if (newseq.getFeatures().hasFeatures())
301 align.addSequence(newseq);
308 * Try to parse a Jalview format feature specification and add it as a
309 * sequence feature to any matching sequences in the alignment. Returns true
310 * if successful (a feature was added), or false if not.
315 * @param featureColours
317 * @param relaxedIdmatching
318 * @param featureGroup
320 protected boolean parseJalviewFeature(String line, String[] gffColumns,
321 AlignmentI alignment, Map<String, FeatureColourI> featureColours,
322 boolean removeHTML, boolean relaxedIdMatching, String featureGroup)
325 * tokens: description seqid seqIndex start end type [score]
327 if (gffColumns.length < 6)
329 System.err.println("Ignoring feature line '" + line
330 + "' with too few columns (" + gffColumns.length + ")");
333 String desc = gffColumns[0];
334 String seqId = gffColumns[1];
335 SequenceI seq = findSequence(seqId, alignment, null, relaxedIdMatching);
337 if (!ID_NOT_SPECIFIED.equals(seqId))
339 seq = findSequence(seqId, alignment, null, relaxedIdMatching);
345 String seqIndex = gffColumns[2];
348 int idx = Integer.parseInt(seqIndex);
349 seq = alignment.getSequenceAt(idx);
350 } catch (NumberFormatException ex)
352 System.err.println("Invalid sequence index: " + seqIndex);
358 System.out.println("Sequence not found: " + line);
362 int startPos = Integer.parseInt(gffColumns[3]);
363 int endPos = Integer.parseInt(gffColumns[4]);
365 String ft = gffColumns[5];
367 if (!featureColours.containsKey(ft))
370 * Perhaps an old style groups file with no colours -
371 * synthesize a colour from the feature type
373 Color colour = ColorUtils.createColourFromName(ft);
374 featureColours.put(ft, new FeatureColour(colour));
376 SequenceFeature sf = new SequenceFeature(ft, desc, "", startPos,
377 endPos, featureGroup);
378 if (gffColumns.length > 6)
380 float score = Float.NaN;
383 score = new Float(gffColumns[6]).floatValue();
384 // update colourgradient bounds if allowed to
385 } catch (NumberFormatException ex)
392 parseDescriptionHTML(sf, removeHTML);
394 seq.addSequenceFeature(sf);
397 && (seq = alignment.findName(seq, seqId, false)) != null)
399 seq.addSequenceFeature(new SequenceFeature(sf));
405 * clear any temporary handles used to speed up ID matching
407 protected void resetMatcher()
409 lastmatchedAl = null;
414 * Returns a sequence matching the given id, as follows
416 * <li>strict matching is on exact sequence name</li>
417 * <li>relaxed matching allows matching on a token within the sequence name,
419 * <li>first tries to find a match in the alignment sequences</li>
420 * <li>else tries to find a match in the new sequences already generated while
421 * parsing the features file</li>
422 * <li>else creates a new placeholder sequence, adds it to the new sequences
423 * list, and returns it</li>
429 * @param relaxedIdMatching
433 protected SequenceI findSequence(String seqId, AlignmentI align,
434 List<SequenceI> newseqs, boolean relaxedIdMatching)
436 // TODO encapsulate in SequenceIdMatcher, share the matcher
437 // with the GffHelper (removing code duplication)
438 SequenceI match = null;
439 if (relaxedIdMatching)
441 if (lastmatchedAl != align)
443 lastmatchedAl = align;
444 matcher = new SequenceIdMatcher(align.getSequencesArray());
447 matcher.addAll(newseqs);
450 match = matcher.findIdMatch(seqId);
454 match = align.findName(seqId, true);
455 if (match == null && newseqs != null)
457 for (SequenceI m : newseqs)
459 if (seqId.equals(m.getName()))
467 if (match == null && newseqs != null)
469 match = new SequenceDummy(seqId);
470 if (relaxedIdMatching)
472 matcher.addAll(Arrays.asList(new SequenceI[] { match }));
474 // add dummy sequence to the newseqs list
480 public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML)
482 if (sf.getDescription() == null)
486 ParseHtmlBodyAndLinks parsed = new ParseHtmlBodyAndLinks(
487 sf.getDescription(), removeHTML, newline);
491 sf.setDescription(parsed.getNonHtmlContent());
494 for (String link : parsed.getLinks())
501 * Returns contents of a Jalview format features file, for visible features,
502 * as filtered by type and group. Features with a null group are displayed if
503 * their feature type is visible. Non-positional features may optionally be
504 * included (with no check on type or group).
509 * map of colour for each visible feature type
510 * @param visibleFeatureGroups
511 * @param includeNonPositional
512 * if true, include non-positional features (regardless of group or
516 public String printJalviewFormat(SequenceI[] sequences,
517 Map<String, FeatureColourI> visible,
518 List<String> visibleFeatureGroups, boolean includeNonPositional)
520 if (!includeNonPositional && (visible == null || visible.isEmpty()))
522 // no point continuing.
523 return "No Features Visible";
527 * write out feature colours (if we know them)
529 // TODO: decide if feature links should also be written here ?
530 StringBuilder out = new StringBuilder(256);
533 for (Entry<String, FeatureColourI> featureColour : visible.entrySet())
535 FeatureColourI colour = featureColour.getValue();
536 out.append(colour.toJalviewFormat(featureColour.getKey())).append(
541 String[] types = visible == null ? new String[0] : visible.keySet()
542 .toArray(new String[visible.keySet().size()]);
545 * sort groups alphabetically, and ensure that null group is output last
547 List<String> sortedGroups = new ArrayList<String>(visibleFeatureGroups);
548 sortedGroups.remove(null);
549 Collections.sort(sortedGroups);
550 sortedGroups.add(null);
552 boolean foundSome = false;
555 * first output any non-positional features
557 if (includeNonPositional)
559 for (int i = 0; i < sequences.length; i++)
561 String sequenceName = sequences[i].getName();
562 for (SequenceFeature feature : sequences[i].getFeatures()
563 .getNonPositionalFeatures())
566 out.append(formatJalviewFeature(sequenceName, feature));
571 for (String group : sortedGroups)
576 out.append("STARTGROUP").append(TAB);
582 * output positional features within groups
584 for (int i = 0; i < sequences.length; i++)
586 String sequenceName = sequences[i].getName();
587 List<SequenceFeature> features = new ArrayList<SequenceFeature>();
588 if (types.length > 0)
590 features.addAll(sequences[i].getFeatures().getFeaturesForGroup(
591 true, group, types));
594 for (SequenceFeature sequenceFeature : features)
597 out.append(formatJalviewFeature(sequenceName, sequenceFeature));
603 out.append("ENDGROUP").append(TAB);
609 return foundSome ? out.toString() : "No Features Visible";
614 * @param sequenceName
615 * @param sequenceFeature
617 protected String formatJalviewFeature(
618 String sequenceName, SequenceFeature sequenceFeature)
620 StringBuilder out = new StringBuilder(64);
621 if (sequenceFeature.description == null
622 || sequenceFeature.description.equals(""))
624 out.append(sequenceFeature.type).append(TAB);
628 if (sequenceFeature.links != null
629 && sequenceFeature.getDescription().indexOf("<html>") == -1)
631 out.append("<html>");
634 out.append(sequenceFeature.description);
635 if (sequenceFeature.links != null)
637 for (int l = 0; l < sequenceFeature.links.size(); l++)
639 String label = sequenceFeature.links.elementAt(l);
640 String href = label.substring(label.indexOf("|") + 1);
641 label = label.substring(0, label.indexOf("|"));
643 if (sequenceFeature.description.indexOf(href) == -1)
645 out.append(" <a href=\"" + href + "\">" + label + "</a>");
649 if (sequenceFeature.getDescription().indexOf("</html>") == -1)
651 out.append("</html>");
657 out.append(sequenceName);
658 out.append("\t-1\t");
659 out.append(sequenceFeature.begin);
661 out.append(sequenceFeature.end);
663 out.append(sequenceFeature.type);
664 if (!Float.isNaN(sequenceFeature.score))
667 out.append(sequenceFeature.score);
671 return out.toString();
675 * Parse method that is called when a GFF file is dragged to the desktop
680 AlignViewportI av = getViewport();
683 if (av.getAlignment() != null)
685 dataset = av.getAlignment().getDataset();
689 // working in the applet context ?
690 dataset = av.getAlignment();
695 dataset = new Alignment(new SequenceI[] {});
698 Map<String, FeatureColourI> featureColours = new HashMap<String, FeatureColourI>();
699 boolean parseResult = parse(dataset, featureColours, false, true);
702 // pass error up somehow
706 // update viewport with the dataset data ?
710 setSeqs(dataset.getSequencesArray());
715 * Implementation of unused abstract method
717 * @return error message
720 public String print(SequenceI[] sqs, boolean jvsuffix)
722 System.out.println("Use printGffFormat() or printJalviewFormat()");
727 * Returns features output in GFF2 format
730 * the sequences whose features are to be output
732 * a map whose keys are the type names of visible features
733 * @param visibleFeatureGroups
734 * @param includeNonPositionalFeatures
737 public String printGffFormat(SequenceI[] sequences,
738 Map<String, FeatureColourI> visible,
739 List<String> visibleFeatureGroups,
740 boolean includeNonPositionalFeatures)
742 StringBuilder out = new StringBuilder(256);
744 out.append(String.format("%s %d\n", GFF_VERSION, gffVersion == 0 ? 2 : gffVersion));
746 if (!includeNonPositionalFeatures
747 && (visible == null || visible.isEmpty()))
749 return out.toString();
752 String[] types = visible == null ? new String[0] : visible.keySet()
754 new String[visible.keySet().size()]);
756 for (SequenceI seq : sequences)
758 List<SequenceFeature> features = new ArrayList<SequenceFeature>();
759 if (includeNonPositionalFeatures)
761 features.addAll(seq.getFeatures().getNonPositionalFeatures());
763 if (visible != null && !visible.isEmpty())
765 features.addAll(seq.getFeatures().getPositionalFeatures(types));
768 for (SequenceFeature sf : features)
770 String source = sf.featureGroup;
771 if (!sf.isNonPositional() && source != null
772 && !visibleFeatureGroups.contains(source))
774 // group is not visible
780 source = sf.getDescription();
783 out.append(seq.getName());
789 out.append(sf.begin);
793 out.append(sf.score);
796 int strand = sf.getStrand();
797 out.append(strand == 1 ? "+" : (strand == -1 ? "-" : "."));
800 String phase = sf.getPhase();
801 out.append(phase == null ? "." : phase);
803 // miscellaneous key-values (GFF column 9)
804 String attributes = sf.getAttributes();
805 if (attributes != null)
807 out.append(TAB).append(attributes);
814 return out.toString();
818 * Returns a mapping given list of one or more Align descriptors (exonerate
821 * @param alignedRegions
822 * a list of "Align fromStart toStart fromCount"
823 * @param mapIsFromCdna
824 * if true, 'from' is dna, else 'from' is protein
826 * either 1 (forward) or -1 (reverse)
828 * @throws IOException
830 protected MapList constructCodonMappingFromAlign(
831 List<String> alignedRegions, boolean mapIsFromCdna, int strand)
836 throw new IOException(
837 "Invalid strand for a codon mapping (cannot be 0)");
839 int regions = alignedRegions.size();
840 // arrays to hold [start, end] for each aligned region
841 int[] fromRanges = new int[regions * 2]; // from dna
842 int[] toRanges = new int[regions * 2]; // to protein
843 int fromRangesIndex = 0;
844 int toRangesIndex = 0;
846 for (String range : alignedRegions)
849 * Align mapFromStart mapToStart mapFromCount
850 * e.g. if mapIsFromCdna
851 * Align 11270 143 120
853 * 120 bases from pos 11270 align to pos 143 in peptide
854 * if !mapIsFromCdna this would instead be
857 String[] tokens = range.split(" ");
858 if (tokens.length != 3)
860 throw new IOException("Wrong number of fields for Align");
867 fromStart = Integer.parseInt(tokens[0]);
868 toStart = Integer.parseInt(tokens[1]);
869 fromCount = Integer.parseInt(tokens[2]);
870 } catch (NumberFormatException nfe)
872 throw new IOException("Invalid number in Align field: "
877 * Jalview always models from dna to protein, so adjust values if the
878 * GFF mapping is from protein to dna
883 int temp = fromStart;
887 fromRanges[fromRangesIndex++] = fromStart;
888 fromRanges[fromRangesIndex++] = fromStart + strand * (fromCount - 1);
891 * If a codon has an intron gap, there will be contiguous 'toRanges';
892 * this is handled for us by the MapList constructor.
893 * (It is not clear that exonerate ever generates this case)
895 toRanges[toRangesIndex++] = toStart;
896 toRanges[toRangesIndex++] = toStart + (fromCount - 1) / 3;
899 return new MapList(fromRanges, toRanges, 3, 1);
903 * Parse a GFF format feature. This may include creating a 'dummy' sequence to
904 * hold the feature, or for its mapped sequence, or both, to be resolved
905 * either later in the GFF file (##FASTA section), or when the user loads
906 * additional sequences.
910 * @param relaxedIdMatching
914 protected SequenceI parseGff(String[] gffColumns, AlignmentI alignment,
915 boolean relaxedIdMatching, List<SequenceI> newseqs)
918 * GFF: seqid source type start end score strand phase [attributes]
920 if (gffColumns.length < 5)
922 System.err.println("Ignoring GFF feature line with too few columns ("
923 + gffColumns.length + ")");
928 * locate referenced sequence in alignment _or_
929 * as a forward or external reference (SequenceDummy)
931 String seqId = gffColumns[0];
932 SequenceI seq = findSequence(seqId, alignment, newseqs,
935 SequenceFeature sf = null;
936 GffHelperI helper = GffHelperFactory.getHelper(gffColumns);
941 sf = helper.processGff(seq, gffColumns, alignment, newseqs,
945 seq.addSequenceFeature(sf);
946 while ((seq = alignment.findName(seq, seqId, true)) != null)
948 seq.addSequenceFeature(new SequenceFeature(sf));
951 } catch (IOException e)
953 System.err.println("GFF parsing failed with: " + e.getMessage());
962 * Process the 'column 9' data of the GFF file. This is less formally defined,
963 * and its interpretation will vary depending on the tool that has generated
969 protected void processGffColumnNine(String attributes, SequenceFeature sf)
971 sf.setAttributes(attributes);
974 * Parse attributes in column 9 and add them to the sequence feature's
975 * 'otherData' table; use Note as a best proxy for description
977 char nameValueSeparator = gffVersion == 3 ? '=' : ' ';
978 // TODO check we don't break GFF2 values which include commas here
979 Map<String, List<String>> nameValues = GffHelperBase
980 .parseNameValuePairs(attributes, ";", nameValueSeparator, ",");
981 for (Entry<String, List<String>> attr : nameValues.entrySet())
983 String values = StringUtils.listToDelimitedString(attr.getValue(),
985 sf.setValue(attr.getKey(), values);
986 if (NOTE.equals(attr.getKey()))
988 sf.setDescription(values);
994 * After encountering ##fasta in a GFF3 file, process the remainder of the
995 * file as FAST sequence data. Any placeholder sequences created during
996 * feature parsing are updated with the actual sequences.
1000 * @throws IOException
1002 protected void processAsFasta(AlignmentI align, List<SequenceI> newseqs)
1008 } catch (IOException q)
1011 FastaFile parser = new FastaFile(this);
1012 List<SequenceI> includedseqs = parser.getSeqs();
1014 SequenceIdMatcher smatcher = new SequenceIdMatcher(newseqs);
1017 * iterate over includedseqs, and replacing matching ones with newseqs
1018 * sequences. Generic iterator not used here because we modify
1019 * includedseqs as we go
1021 for (int p = 0, pSize = includedseqs.size(); p < pSize; p++)
1023 // search for any dummy seqs that this sequence can be used to update
1024 SequenceI includedSeq = includedseqs.get(p);
1025 SequenceI dummyseq = smatcher.findIdMatch(includedSeq);
1026 if (dummyseq != null && dummyseq instanceof SequenceDummy)
1028 // probably have the pattern wrong
1029 // idea is that a flyweight proxy for a sequence ID can be created for
1030 // 1. stable reference creation
1031 // 2. addition of annotation
1032 // 3. future replacement by a real sequence
1033 // current pattern is to create SequenceDummy objects - a convenience
1034 // constructor for a Sequence.
1035 // problem is that when promoted to a real sequence, all references
1036 // need to be updated somehow. We avoid that by keeping the same object.
1037 ((SequenceDummy) dummyseq).become(includedSeq);
1038 dummyseq.createDatasetSequence();
1041 * Update mappings so they are now to the dataset sequence
1043 for (AlignedCodonFrame mapping : align.getCodonFrames())
1045 mapping.updateToDataset(dummyseq);
1049 * replace parsed sequence with the realised forward reference
1051 includedseqs.set(p, dummyseq);
1054 * and remove from the newseqs list
1056 newseqs.remove(dummyseq);
1061 * finally add sequences to the dataset
1063 for (SequenceI seq : includedseqs)
1065 // experimental: mapping-based 'alignment' to query sequence
1066 AlignmentUtils.alignSequenceAs(seq, align,
1067 String.valueOf(align.getGapCharacter()), false, true);
1069 // rename sequences if GFF handler requested this
1070 // TODO a more elegant way e.g. gffHelper.postProcess(newseqs) ?
1071 List<SequenceFeature> sfs = seq.getFeatures().getPositionalFeatures();
1074 String newName = (String) sfs.get(0).getValue(
1075 GffHelperI.RENAME_TOKEN);
1076 if (newName != null)
1078 seq.setName(newName);
1081 align.addSequence(seq);
1086 * Process a ## directive
1092 * @throws IOException
1094 protected void processGffPragma(String line,
1095 Map<String, String> gffProps, AlignmentI align,
1096 List<SequenceI> newseqs) throws IOException
1099 if ("###".equals(line))
1101 // close off any open 'forward references'
1105 String[] tokens = line.substring(2).split(" ");
1106 String pragma = tokens[0];
1107 String value = tokens.length == 1 ? null : tokens[1];
1109 if ("gff-version".equalsIgnoreCase(pragma))
1115 // value may be e.g. "3.1.2"
1116 gffVersion = Integer.parseInt(value.split("\\.")[0]);
1117 } catch (NumberFormatException e)
1123 else if ("sequence-region".equalsIgnoreCase(pragma))
1125 // could capture <seqid start end> if wanted here
1127 else if ("feature-ontology".equalsIgnoreCase(pragma))
1129 // should resolve against the specified feature ontology URI
1131 else if ("attribute-ontology".equalsIgnoreCase(pragma))
1133 // URI of attribute ontology - not currently used in GFF3
1135 else if ("source-ontology".equalsIgnoreCase(pragma))
1137 // URI of source ontology - not currently used in GFF3
1139 else if ("species-build".equalsIgnoreCase(pragma))
1141 // save URI of specific NCBI taxon version of annotations
1142 gffProps.put("species-build", value);
1144 else if ("fasta".equalsIgnoreCase(pragma))
1146 // process the rest of the file as a fasta file and replace any dummy
1148 processAsFasta(align, newseqs);
1152 System.err.println("Ignoring unknown pragma: " + line);