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.
24 import jalview.api.AlignExportSettingI;
25 import jalview.api.AlignViewportI;
26 import jalview.api.AlignmentViewPanel;
27 import jalview.api.ComplexAlignFile;
28 import jalview.api.FeatureRenderer;
29 import jalview.api.FeatureSettingsModelI;
30 import jalview.api.FeaturesDisplayedI;
31 import jalview.bin.BuildDetails;
32 import jalview.datamodel.AlignExportSettingBeanI;
33 import jalview.datamodel.AlignmentAnnotation;
34 import jalview.datamodel.AlignmentI;
35 import jalview.datamodel.Annotation;
36 import jalview.datamodel.HiddenColumns;
37 import jalview.datamodel.HiddenSequences;
38 import jalview.datamodel.Sequence;
39 import jalview.datamodel.SequenceFeature;
40 import jalview.datamodel.SequenceGroup;
41 import jalview.datamodel.SequenceI;
42 import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo;
43 import jalview.json.binding.biojson.v1.AlignmentPojo;
44 import jalview.json.binding.biojson.v1.AnnotationDisplaySettingPojo;
45 import jalview.json.binding.biojson.v1.AnnotationPojo;
46 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
47 import jalview.json.binding.biojson.v1.SequenceFeaturesPojo;
48 import jalview.json.binding.biojson.v1.SequenceGrpPojo;
49 import jalview.json.binding.biojson.v1.SequencePojo;
50 import jalview.renderer.seqfeatures.FeatureColourFinder;
51 import jalview.schemes.ColourSchemeProperty;
52 import jalview.schemes.JalviewColourScheme;
53 import jalview.schemes.ResidueColourScheme;
54 import jalview.util.ColorUtils;
55 import jalview.util.Format;
56 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
58 import java.awt.Color;
59 import java.io.IOException;
60 import java.io.Reader;
61 import java.util.ArrayList;
62 import java.util.Hashtable;
63 import java.util.Iterator;
64 import java.util.List;
65 import java.util.Vector;
67 import org.json.simple.JSONArray;
68 import org.json.simple.JSONObject;
69 import org.json.simple.parser.JSONParser;
71 public class JSONFile extends AlignFile implements ComplexAlignFile
73 private static String version = new BuildDetails().getVersion();
75 private String webstartUrl = "http://www.jalview.org/services/launchApp";
77 private String application = "Jalview";
79 private String globalColourScheme;
81 private boolean showSeqFeatures;
83 private Hashtable<String, Sequence> seqMap;
85 private FeaturesDisplayedI displayedFeatures;
87 private FeatureRenderer fr;
89 private HiddenColumns hiddenColumns;
91 private List<String> hiddenSeqRefs;
93 private ArrayList<SequenceI> hiddenSequences;
95 private final static String TCOFFEE_SCORE = "TCoffeeScore";
102 public JSONFile(FileParse source) throws IOException
107 public JSONFile(String inFile, DataSourceType sourceType)
110 super(inFile, sourceType);
114 public void parse() throws IOException
121 public String print(SequenceI[] sqs, boolean jvsuffix)
123 String jsonOutput = null;
126 AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
127 AlignExportSettingBeanI exportSettings = getExportSettings();
129 // if no export settings were supplied use the following with all values
130 // defaulting to true
131 if (exportSettings == null)
133 exportSettings = new AlignExportSettingBeanI()
136 public boolean isExportHiddenSequences()
142 public boolean isExportHiddenColumns()
148 public boolean isExportGroups()
154 public boolean isExportFeatures()
160 public boolean isExportAnnotations()
166 public boolean isCancelled()
174 for (SequenceI seq : sqs)
176 StringBuilder name = new StringBuilder();
177 name.append(seq.getName()).append("/").append(seq.getStart())
178 .append("-").append(seq.getEnd());
179 SequencePojo jsonSeqPojo = new SequencePojo();
180 jsonSeqPojo.setId(String.valueOf(seq.hashCode()));
181 jsonSeqPojo.setOrder(++count);
182 jsonSeqPojo.setEnd(seq.getEnd());
183 jsonSeqPojo.setStart(seq.getStart());
184 jsonSeqPojo.setName(name.toString());
185 jsonSeqPojo.setSeq(seq.getSequenceAsString());
186 jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
188 jsonAlignmentPojo.setGlobalColorScheme(globalColourScheme);
189 jsonAlignmentPojo.getAppSettings().put("application", application);
190 jsonAlignmentPojo.getAppSettings().put("version", version);
191 jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
192 jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
193 String.valueOf(showSeqFeatures));
195 String[] hiddenSections = getHiddenSections();
196 if (hiddenSections != null)
198 if (hiddenSections[0] != null
199 && exportSettings.isExportHiddenColumns())
201 jsonAlignmentPojo.getAppSettings().put("hiddenCols",
202 String.valueOf(hiddenSections[0]));
204 if (hiddenSections[1] != null
205 && exportSettings.isExportHiddenSequences())
207 jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
208 String.valueOf(hiddenSections[1]));
212 if (exportSettings.isExportAnnotations())
215 .setAlignAnnotation(annotationToJsonPojo(annotations));
219 // These color schemes require annotation, disable them if annotations
221 if (globalColourScheme
222 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
223 || globalColourScheme.equalsIgnoreCase(
224 JalviewColourScheme.TCoffee.toString()))
226 jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
230 if (exportSettings.isExportFeatures())
232 jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(sqs));
235 if (exportSettings.isExportGroups() && seqGroups != null
236 && seqGroups.size() > 0)
238 for (SequenceGroup seqGrp : seqGroups)
240 SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
241 seqGrpPojo.setGroupName(seqGrp.getName());
242 seqGrpPojo.setColourScheme(ColourSchemeProperty
243 .getColourName(seqGrp.getColourScheme()));
244 seqGrpPojo.setColourText(seqGrp.getColourText());
245 seqGrpPojo.setDescription(seqGrp.getDescription());
246 seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
247 seqGrpPojo.setDisplayText(seqGrp.getDisplayText());
248 seqGrpPojo.setEndRes(seqGrp.getEndRes());
249 seqGrpPojo.setStartRes(seqGrp.getStartRes());
250 seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
251 for (SequenceI seq : seqGrp.getSequences())
253 seqGrpPojo.getSequenceRefs()
254 .add(String.valueOf(seq.hashCode()));
256 jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo);
259 org.json.JSONObject generatedJSon = new org.json.JSONObject(
261 jsonOutput = generatedJSon.toString();
262 return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend",
264 } catch (Exception e)
271 public String[] getHiddenSections()
273 String[] hiddenSections = new String[2];
274 if (getViewport() == null)
279 // hidden column business
280 if (getViewport().hasHiddenColumns())
282 hiddenSections[0] = getViewport().getAlignment().getHiddenColumns()
283 .regionsToString(";", "-");
286 // hidden rows/seqs business
287 HiddenSequences hiddenSeqsObj = getViewport().getAlignment()
288 .getHiddenSequences();
289 if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null)
291 return hiddenSections;
294 SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences;
295 StringBuilder hiddenSeqsBuilder = new StringBuilder();
296 for (SequenceI hiddenSeq : hiddenSeqs)
298 if (hiddenSeq != null)
300 hiddenSeqsBuilder.append(";").append(hiddenSeq.hashCode());
303 if (hiddenSeqsBuilder.length() > 0)
305 hiddenSeqsBuilder.deleteCharAt(0);
307 hiddenSections[1] = hiddenSeqsBuilder.toString();
309 return hiddenSections;
312 protected List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
315 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
316 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<>();
319 return sequenceFeaturesPojo;
322 FeatureColourFinder finder = new FeatureColourFinder(fr);
324 String[] visibleFeatureTypes = displayedFeatures == null ? null
325 : displayedFeatures.getVisibleFeatures().toArray(
326 new String[displayedFeatures.getVisibleFeatureCount()]);
328 for (SequenceI seq : sqs)
331 * get all features currently visible (and any non-positional features)
333 List<SequenceFeature> seqFeatures = seq.getFeatures().getAllFeatures(
334 visibleFeatureTypes);
335 for (SequenceFeature sf : seqFeatures)
337 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
338 String.valueOf(seq.hashCode()));
340 String featureColour = (fr == null) ? null : Format
341 .getHexString(finder.findFeatureColour(Color.white, seq,
342 seq.findIndex(sf.getBegin())));
343 int xStart = sf.getBegin() == 0 ? 0
344 : seq.findIndex(sf.getBegin()) - 1;
345 int xEnd = sf.getEnd() == 0 ? 0 : seq.findIndex(sf.getEnd());
346 jsonFeature.setXstart(xStart);
347 jsonFeature.setXend(xEnd);
348 jsonFeature.setType(sf.getType());
349 jsonFeature.setDescription(sf.getDescription());
350 jsonFeature.setLinks(sf.links);
351 jsonFeature.setOtherDetails(sf.otherDetails);
352 jsonFeature.setScore(sf.getScore());
353 jsonFeature.setFillColor(featureColour);
354 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
355 sequenceFeaturesPojo.add(jsonFeature);
358 return sequenceFeaturesPojo;
361 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
362 Vector<AlignmentAnnotation> annotations)
364 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<>();
365 if (annotations == null)
367 return jsonAnnotations;
369 for (AlignmentAnnotation annot : annotations)
371 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
372 alignAnnotPojo.setDescription(annot.description);
373 alignAnnotPojo.setLabel(annot.label);
374 if (!Double.isNaN(annot.score))
376 alignAnnotPojo.setScore(annot.score);
378 alignAnnotPojo.setCalcId(annot.getCalcId());
379 alignAnnotPojo.setGraphType(annot.graph);
381 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
382 annotSetting.setBelowAlignment(annot.belowAlignment);
383 annotSetting.setCentreColLabels(annot.centreColLabels);
384 annotSetting.setScaleColLabel(annot.scaleColLabel);
385 annotSetting.setShowAllColLabels(annot.showAllColLabels);
386 annotSetting.setVisible(annot.visible);
387 annotSetting.setHasIcon(annot.hasIcons);
388 alignAnnotPojo.setAnnotationSettings(annotSetting);
389 SequenceI refSeq = annot.sequenceRef;
392 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
394 for (Annotation annotation : annot.annotations)
396 AnnotationPojo annotationPojo = new AnnotationPojo();
397 if (annotation != null)
399 annotationPojo.setDescription(annotation.description);
400 annotationPojo.setValue(annotation.value);
402 .setSecondaryStructure(annotation.secondaryStructure);
403 String displayChar = annotation.displayCharacter == null ? null
404 : annotation.displayCharacter;
405 // System.out.println("--------------------->[" + displayChar + "]");
406 annotationPojo.setDisplayCharacter(displayChar);
407 if (annotation.colour != null)
409 annotationPojo.setColour(
410 jalview.util.Format.getHexString(annotation.colour));
412 alignAnnotPojo.getAnnotations().add(annotationPojo);
416 if (annot.getCalcId() != null
417 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
423 alignAnnotPojo.getAnnotations().add(annotationPojo);
427 jsonAnnotations.add(alignAnnotPojo);
429 return jsonAnnotations;
432 @SuppressWarnings("unchecked")
433 public JSONFile parse(Reader jsonAlignmentString)
437 JSONParser jsonParser = new JSONParser();
438 JSONObject alignmentJsonObj = (JSONObject) jsonParser
439 .parse(jsonAlignmentString);
440 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
441 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
442 .get("alignAnnotation");
443 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
445 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
447 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
450 if (jvSettingsJsonObj != null)
452 globalColourScheme = (String) jvSettingsJsonObj
453 .get("globalColorScheme");
454 Boolean showFeatures = Boolean.valueOf(
455 jvSettingsJsonObj.get("showSeqFeatures").toString());
456 setShowSeqFeatures(showFeatures);
457 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
458 parseHiddenCols(jvSettingsJsonObj);
461 hiddenSequences = new ArrayList<>();
462 seqMap = new Hashtable<>();
463 for (Iterator<JSONObject> sequenceIter = seqJsonArray
464 .iterator(); sequenceIter.hasNext();)
466 JSONObject sequence = sequenceIter.next();
467 String sequcenceString = sequence.get("seq").toString();
468 String sequenceName = sequence.get("name").toString();
469 String seqUniqueId = sequence.get("id").toString();
470 int start = Integer.valueOf(sequence.get("start").toString());
471 int end = Integer.valueOf(sequence.get("end").toString());
472 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
474 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
476 hiddenSequences.add(seq);
479 seqMap.put(seqUniqueId, seq);
482 parseFeatures(jsonSeqArray);
484 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray
485 .iterator(); seqGrpIter.hasNext();)
487 JSONObject seqGrpObj = seqGrpIter.next();
488 String grpName = seqGrpObj.get("groupName").toString();
489 String colourScheme = seqGrpObj.get("colourScheme").toString();
490 String description = (seqGrpObj.get("description") == null) ? null
491 : seqGrpObj.get("description").toString();
492 boolean displayBoxes = Boolean
493 .valueOf(seqGrpObj.get("displayBoxes").toString());
494 boolean displayText = Boolean
495 .valueOf(seqGrpObj.get("displayText").toString());
496 boolean colourText = Boolean
497 .valueOf(seqGrpObj.get("colourText").toString());
498 boolean showNonconserved = Boolean
499 .valueOf(seqGrpObj.get("showNonconserved").toString());
500 int startRes = Integer
501 .valueOf(seqGrpObj.get("startRes").toString());
502 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
503 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
505 ArrayList<SequenceI> grpSeqs = new ArrayList<>();
506 if (sequenceRefs.size() > 0)
508 Iterator<String> seqHashIter = sequenceRefs.iterator();
509 while (seqHashIter.hasNext())
511 String seqHash = seqHashIter.next();
512 Sequence sequence = seqMap.get(seqHash);
513 if (sequence != null)
515 grpSeqs.add(sequence);
519 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
520 displayBoxes, displayText, colourText, startRes, endRes);
521 seqGrp.setColourScheme(ColourSchemeMapper
522 .getJalviewColourScheme(colourScheme, seqGrp));
523 seqGrp.setShowNonconserved(showNonconserved);
524 seqGrp.setDescription(description);
525 this.seqGroups.add(seqGrp);
529 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray
530 .iterator(); alAnnotIter.hasNext();)
532 JSONObject alAnnot = alAnnotIter.next();
533 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
534 Annotation[] annotations = new Annotation[annotJsonArray.size()];
536 for (Iterator<JSONObject> annotIter = annotJsonArray
537 .iterator(); annotIter.hasNext();)
539 JSONObject annot = annotIter.next();
542 annotations[count] = null;
546 float val = annot.get("value") == null ? null
547 : Float.valueOf(annot.get("value").toString());
548 String desc = annot.get("description") == null ? null
549 : annot.get("description").toString();
550 char ss = annot.get("secondaryStructure") == null
551 || annot.get("secondaryStructure").toString()
552 .equalsIgnoreCase("u0000") ? ' '
553 : annot.get("secondaryStructure")
554 .toString().charAt(0);
555 String displayChar = annot.get("displayCharacter") == null ? ""
556 : annot.get("displayCharacter").toString();
558 annotations[count] = new Annotation(displayChar, desc, ss, val);
559 if (annot.get("colour") != null)
561 Color color = ColorUtils
562 .parseColourString(annot.get("colour").toString());
563 annotations[count].colour = color;
569 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(
570 alAnnot.get("label").toString(),
571 alAnnot.get("description").toString(), annotations);
572 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0
573 : Integer.valueOf(alAnnot.get("graphType").toString());
575 JSONObject diplaySettings = (JSONObject) alAnnot
576 .get("annotationSettings");
577 if (diplaySettings != null)
580 alignAnnot.scaleColLabel = (diplaySettings
581 .get("scaleColLabel") == null) ? false
582 : Boolean.valueOf(diplaySettings
583 .get("scaleColLabel").toString());
584 alignAnnot.showAllColLabels = (diplaySettings
585 .get("showAllColLabels") == null) ? true
586 : Boolean.valueOf(diplaySettings
587 .get("showAllColLabels").toString());
588 alignAnnot.centreColLabels = (diplaySettings
589 .get("centreColLabels") == null) ? true
590 : Boolean.valueOf(diplaySettings
591 .get("centreColLabels").toString());
592 alignAnnot.belowAlignment = (diplaySettings
593 .get("belowAlignment") == null) ? false
594 : Boolean.valueOf(diplaySettings
595 .get("belowAlignment").toString());
596 alignAnnot.visible = (diplaySettings.get("visible") == null)
599 diplaySettings.get("visible").toString());
600 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null)
603 diplaySettings.get("hasIcon").toString());
606 if (alAnnot.get("score") != null)
608 alignAnnot.score = Double
609 .valueOf(alAnnot.get("score").toString());
612 String calcId = (alAnnot.get("calcId") == null) ? ""
613 : alAnnot.get("calcId").toString();
614 alignAnnot.setCalcId(calcId);
615 String seqHash = (alAnnot.get("sequenceRef") != null)
616 ? alAnnot.get("sequenceRef").toString()
619 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
620 if (sequence != null)
622 alignAnnot.sequenceRef = sequence;
623 sequence.addAlignmentAnnotation(alignAnnot);
624 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
626 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
628 sequence.addAlignmentAnnotation(alignAnnot);
629 alignAnnot.adjustForAlignment();
632 alignAnnot.validateRangeAndDisplay();
633 this.annotations.add(alignAnnot);
636 } catch (Exception e)
643 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
645 hiddenSeqRefs = new ArrayList<>();
646 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
647 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
649 String[] seqRefs = hiddenSeqs.split(";");
650 for (String seqRef : seqRefs)
652 hiddenSeqRefs.add(seqRef);
657 public void parseHiddenCols(JSONObject jvSettingsJson)
659 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
660 if (hiddenCols != null && !hiddenCols.isEmpty())
662 hiddenColumns = new HiddenColumns();
663 String[] rangeStrings = hiddenCols.split(";");
664 for (String rangeString : rangeStrings)
666 String[] range = rangeString.split("-");
667 hiddenColumns.hideColumns(Integer.valueOf(range[0]),
668 Integer.valueOf(range[1]));
673 @SuppressWarnings("unchecked")
674 private void parseFeatures(JSONArray jsonSeqFeatures)
676 if (jsonSeqFeatures != null)
678 displayedFeatures = new FeaturesDisplayed();
679 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures
680 .iterator(); seqFeatureItr.hasNext();)
682 JSONObject jsonFeature = seqFeatureItr.next();
683 Long begin = (Long) jsonFeature.get("xStart");
684 Long end = (Long) jsonFeature.get("xEnd");
685 String type = (String) jsonFeature.get("type");
686 String featureGrp = (String) jsonFeature.get("featureGroup");
687 String description = (String) jsonFeature.get("description");
688 String seqRef = (String) jsonFeature.get("sequenceRef");
689 Float score = Float.valueOf(jsonFeature.get("score").toString());
691 Sequence seq = seqMap.get(seqRef);
694 * begin/end of 0 is for a non-positional feature
696 int featureBegin = begin.intValue() == 0 ? 0 : seq
697 .findPosition(begin.intValue());
698 int featureEnd = end.intValue() == 0 ? 0 : seq.findPosition(end
701 SequenceFeature sequenceFeature = new SequenceFeature(type,
702 description, featureBegin, featureEnd, score, featureGrp);
704 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
705 if (linksJsonArray != null && linksJsonArray.size() > 0)
707 Iterator<String> linkList = linksJsonArray.iterator();
708 while (linkList.hasNext())
710 String link = linkList.next();
711 sequenceFeature.addLink(link);
715 seq.addSequenceFeature(sequenceFeature);
716 displayedFeatures.setVisible(type);
722 public String getGlobalColourScheme()
724 return globalColourScheme;
727 public void setGlobalColorScheme(String globalColourScheme)
729 this.globalColourScheme = globalColourScheme;
733 public FeaturesDisplayedI getDisplayedFeatures()
735 return displayedFeatures;
738 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
740 this.displayedFeatures = displayedFeatures;
744 public void configureForView(AlignmentViewPanel avpanel)
750 super.configureForView(avpanel);
751 AlignViewportI viewport = avpanel.getAlignViewport();
752 AlignmentI alignment = viewport.getAlignment();
753 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
755 seqGroups = alignment.getGroups();
756 fr = avpanel.cloneFeatureRenderer();
758 // Add non auto calculated annotation to AlignFile
761 for (AlignmentAnnotation annot : annots)
763 if (annot != null && !annot.autoCalculated)
765 annotations.add(annot);
769 globalColourScheme = ColourSchemeProperty
770 .getColourName(viewport.getGlobalColourScheme());
771 setDisplayedFeatures(viewport.getFeaturesDisplayed());
772 showSeqFeatures = viewport.isShowSequenceFeatures();
777 public boolean isShowSeqFeatures()
779 return showSeqFeatures;
782 public void setShowSeqFeatures(boolean showSeqFeatures)
784 this.showSeqFeatures = showSeqFeatures;
787 public Vector<AlignmentAnnotation> getAnnotations()
793 public HiddenColumns getHiddenColumns()
795 return hiddenColumns;
798 public void setHiddenColumns(HiddenColumns hidden)
800 this.hiddenColumns = hidden;
804 public SequenceI[] getHiddenSequences()
806 if (hiddenSequences == null || hiddenSequences.isEmpty())
808 return new SequenceI[] {};
810 synchronized (hiddenSequences)
812 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
816 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
818 this.hiddenSequences = hiddenSequences;
821 public class JSONExportSettings
823 private boolean exportSequence;
825 private boolean exportSequenceFeatures;
827 private boolean exportAnnotations;
829 private boolean exportGroups;
831 private boolean exportJalviewSettings;
833 public boolean isExportSequence()
835 return exportSequence;
838 public void setExportSequence(boolean exportSequence)
840 this.exportSequence = exportSequence;
843 public boolean isExportSequenceFeatures()
845 return exportSequenceFeatures;
848 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
850 this.exportSequenceFeatures = exportSequenceFeatures;
853 public boolean isExportAnnotations()
855 return exportAnnotations;
858 public void setExportAnnotations(boolean exportAnnotations)
860 this.exportAnnotations = exportAnnotations;
863 public boolean isExportGroups()
868 public void setExportGroups(boolean exportGroups)
870 this.exportGroups = exportGroups;
873 public boolean isExportJalviewSettings()
875 return exportJalviewSettings;
878 public void setExportJalviewSettings(boolean exportJalviewSettings)
880 this.exportJalviewSettings = exportJalviewSettings;
885 * Returns a descriptor for suitable feature display settings with
887 * <li>ResNums or insertions features visible</li>
888 * <li>insertions features coloured red</li>
889 * <li>ResNum features coloured by label</li>
890 * <li>Insertions displayed above (on top of) ResNums</li>
894 public FeatureSettingsModelI getFeatureColourScheme()
896 return new PDBFeatureSettings();