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.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.Annotation;
35 import jalview.datamodel.ColumnSelection;
36 import jalview.datamodel.HiddenSequences;
37 import jalview.datamodel.Sequence;
38 import jalview.datamodel.SequenceFeature;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo;
42 import jalview.json.binding.biojson.v1.AlignmentPojo;
43 import jalview.json.binding.biojson.v1.AnnotationDisplaySettingPojo;
44 import jalview.json.binding.biojson.v1.AnnotationPojo;
45 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
46 import jalview.json.binding.biojson.v1.SequenceFeaturesPojo;
47 import jalview.json.binding.biojson.v1.SequenceGrpPojo;
48 import jalview.json.binding.biojson.v1.SequencePojo;
49 import jalview.schemes.JalviewColourScheme;
50 import jalview.schemes.ResidueColourScheme;
51 import jalview.util.ColorUtils;
52 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
54 import java.awt.Color;
55 import java.io.IOException;
56 import java.io.Reader;
57 import java.util.ArrayList;
58 import java.util.Hashtable;
59 import java.util.Iterator;
60 import java.util.List;
61 import java.util.Vector;
63 import org.json.simple.JSONArray;
64 import org.json.simple.JSONObject;
65 import org.json.simple.parser.JSONParser;
67 public class JSONFile extends AlignFile implements ComplexAlignFile
69 private static String version = new BuildDetails().getVersion();
71 private String webstartUrl = "http://www.jalview.org/services/launchApp";
73 private String application = "Jalview";
75 private String globalColourScheme;
77 private boolean showSeqFeatures;
79 private Hashtable<String, Sequence> seqMap;
81 private FeaturesDisplayedI displayedFeatures;
83 private FeatureRenderer fr;
85 private List<int[]> hiddenColumns;
87 private ColumnSelection columnSelection;
89 private List<String> hiddenSeqRefs;
91 private ArrayList<SequenceI> hiddenSequences;
93 private final static String TCOFFEE_SCORE = "TCoffeeScore";
100 public JSONFile(FileParse source) throws IOException
105 public JSONFile(String inFile, DataSourceType sourceType)
108 super(inFile, sourceType);
112 public void parse() throws IOException
119 public String print(SequenceI[] sqs, boolean jvsuffix)
121 String jsonOutput = null;
124 AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
125 AlignExportSettingI exportSettings = getExportSettings();
127 // if no export settings were supplied use the following with all values
128 // defaulting to true
129 if (exportSettings == null)
131 exportSettings = new AlignExportSettingI()
134 public boolean isExportHiddenSequences()
140 public boolean isExportHiddenColumns()
146 public boolean isExportGroups()
152 public boolean isExportFeatures()
158 public boolean isExportAnnotations()
164 public boolean isCancelled()
172 for (SequenceI seq : sqs)
174 StringBuilder name = new StringBuilder();
175 name.append(seq.getName()).append("/").append(seq.getStart())
176 .append("-").append(seq.getEnd());
177 SequencePojo jsonSeqPojo = new SequencePojo();
178 jsonSeqPojo.setId(String.valueOf(seq.hashCode()));
179 jsonSeqPojo.setOrder(++count);
180 jsonSeqPojo.setEnd(seq.getEnd());
181 jsonSeqPojo.setStart(seq.getStart());
182 jsonSeqPojo.setName(name.toString());
183 jsonSeqPojo.setSeq(seq.getSequenceAsString());
184 jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
186 jsonAlignmentPojo.setGlobalColorScheme(globalColourScheme);
187 jsonAlignmentPojo.getAppSettings().put("application", application);
188 jsonAlignmentPojo.getAppSettings().put("version", version);
189 jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
190 jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
191 String.valueOf(showSeqFeatures));
193 String[] hiddenSections = getHiddenSections();
194 if (hiddenSections != null)
196 if (hiddenSections[0] != null
197 && exportSettings.isExportHiddenColumns())
199 jsonAlignmentPojo.getAppSettings().put("hiddenCols",
200 String.valueOf(hiddenSections[0]));
202 if (hiddenSections[1] != null
203 && exportSettings.isExportHiddenSequences())
205 jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
206 String.valueOf(hiddenSections[1]));
210 if (exportSettings.isExportAnnotations())
213 .setAlignAnnotation(annotationToJsonPojo(annotations));
217 // These color schemes require annotation, disable them if annotations
219 if (globalColourScheme
220 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
221 || globalColourScheme
222 .equalsIgnoreCase(JalviewColourScheme.TCoffee
225 jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
229 if (exportSettings.isExportFeatures())
232 .setSeqFeatures(sequenceFeatureToJsonPojo(sqs, fr));
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(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 List<int[]> hiddenCols = getViewport().getColumnSelection()
284 StringBuilder hiddenColsBuilder = new StringBuilder();
285 for (int[] range : hiddenCols)
287 hiddenColsBuilder.append(";").append(range[0]).append("-")
291 hiddenColsBuilder.deleteCharAt(0);
292 hiddenSections[0] = hiddenColsBuilder.toString();
295 // hidden rows/seqs business
296 HiddenSequences hiddenSeqsObj = getViewport().getAlignment()
297 .getHiddenSequences();
298 if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null)
300 return hiddenSections;
303 SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences;
304 StringBuilder hiddenSeqsBuilder = new StringBuilder();
305 for (SequenceI hiddenSeq : hiddenSeqs)
307 if (hiddenSeq != null)
309 hiddenSeqsBuilder.append(";").append(hiddenSeq.hashCode());
312 if (hiddenSeqsBuilder.length() > 0)
314 hiddenSeqsBuilder.deleteCharAt(0);
316 hiddenSections[1] = hiddenSeqsBuilder.toString();
318 return hiddenSections;
321 public List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
322 SequenceI[] sqs, FeatureRenderer fr)
324 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
325 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
328 return sequenceFeaturesPojo;
331 for (SequenceI seq : sqs)
333 SequenceI dataSetSequence = seq.getDatasetSequence();
334 SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null
335 : seq.getDatasetSequence().getSequenceFeatures();
337 seqFeatures = (seqFeatures == null) ? seq.getSequenceFeatures()
339 if (seqFeatures == null)
344 for (SequenceFeature sf : seqFeatures)
346 if (displayedFeatures != null
347 && displayedFeatures.isVisible(sf.getType()))
349 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
350 String.valueOf(seq.hashCode()));
352 String featureColour = (fr == null) ? null : jalview.util.Format
353 .getHexString(fr.findFeatureColour(Color.white, seq,
354 seq.findIndex(sf.getBegin())));
355 jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
356 jsonFeature.setXend(seq.findIndex(sf.getEnd()));
357 jsonFeature.setType(sf.getType());
358 jsonFeature.setDescription(sf.getDescription());
359 jsonFeature.setLinks(sf.links);
360 jsonFeature.setOtherDetails(sf.otherDetails);
361 jsonFeature.setScore(sf.getScore());
362 jsonFeature.setFillColor(featureColour);
363 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
364 sequenceFeaturesPojo.add(jsonFeature);
368 return sequenceFeaturesPojo;
371 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
372 Vector<AlignmentAnnotation> annotations)
374 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
375 if (annotations == null)
377 return jsonAnnotations;
379 for (AlignmentAnnotation annot : annotations)
381 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
382 alignAnnotPojo.setDescription(annot.description);
383 alignAnnotPojo.setLabel(annot.label);
384 if (!Double.isNaN(annot.score))
386 alignAnnotPojo.setScore(annot.score);
388 alignAnnotPojo.setCalcId(annot.getCalcId());
389 alignAnnotPojo.setGraphType(annot.graph);
391 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
392 annotSetting.setBelowAlignment(annot.belowAlignment);
393 annotSetting.setCentreColLabels(annot.centreColLabels);
394 annotSetting.setScaleColLabel(annot.scaleColLabel);
395 annotSetting.setShowAllColLabels(annot.showAllColLabels);
396 annotSetting.setVisible(annot.visible);
397 annotSetting.setHasIcon(annot.hasIcons);
398 alignAnnotPojo.setAnnotationSettings(annotSetting);
399 SequenceI refSeq = annot.sequenceRef;
402 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
404 for (Annotation annotation : annot.annotations)
406 AnnotationPojo annotationPojo = new AnnotationPojo();
407 if (annotation != null)
409 annotationPojo.setDescription(annotation.description);
410 annotationPojo.setValue(annotation.value);
412 .setSecondaryStructure(annotation.secondaryStructure);
413 String displayChar = annotation.displayCharacter == null ? null
414 : annotation.displayCharacter;
415 // System.out.println("--------------------->[" + displayChar + "]");
416 annotationPojo.setDisplayCharacter(displayChar);
417 if (annotation.colour != null)
419 annotationPojo.setColour(jalview.util.Format
420 .getHexString(annotation.colour));
422 alignAnnotPojo.getAnnotations().add(annotationPojo);
426 if (annot.getCalcId() != null
427 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
433 alignAnnotPojo.getAnnotations().add(annotationPojo);
437 jsonAnnotations.add(alignAnnotPojo);
439 return jsonAnnotations;
442 @SuppressWarnings("unchecked")
443 public JSONFile parse(Reader jsonAlignmentString)
447 JSONParser jsonParser = new JSONParser();
448 JSONObject alignmentJsonObj = (JSONObject) jsonParser
449 .parse(jsonAlignmentString);
450 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
451 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
452 .get("alignAnnotation");
453 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
455 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
457 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
460 if (jvSettingsJsonObj != null)
462 globalColourScheme = (String) jvSettingsJsonObj
463 .get("globalColorScheme");
464 Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
465 "showSeqFeatures").toString());
466 setShowSeqFeatures(showFeatures);
467 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
468 parseHiddenCols(jvSettingsJsonObj);
471 hiddenSequences = new ArrayList<SequenceI>();
472 seqMap = new Hashtable<String, Sequence>();
473 for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
476 JSONObject sequence = sequenceIter.next();
477 String sequcenceString = sequence.get("seq").toString();
478 String sequenceName = sequence.get("name").toString();
479 String seqUniqueId = sequence.get("id").toString();
480 int start = Integer.valueOf(sequence.get("start").toString());
481 int end = Integer.valueOf(sequence.get("end").toString());
482 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
484 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
486 hiddenSequences.add(seq);
489 seqMap.put(seqUniqueId, seq);
492 parseFeatures(jsonSeqArray);
494 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
497 JSONObject seqGrpObj = seqGrpIter.next();
498 String grpName = seqGrpObj.get("groupName").toString();
499 String colourScheme = seqGrpObj.get("colourScheme").toString();
500 String description = (seqGrpObj.get("description") == null) ? null
501 : seqGrpObj.get("description").toString();
502 boolean displayBoxes = Boolean.valueOf(seqGrpObj
503 .get("displayBoxes").toString());
504 boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
506 boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
508 boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
509 "showNonconserved").toString());
510 int startRes = Integer
511 .valueOf(seqGrpObj.get("startRes").toString());
512 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
513 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
515 ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
516 if (sequenceRefs.size() > 0)
518 Iterator<String> seqHashIter = sequenceRefs.iterator();
519 while (seqHashIter.hasNext())
521 String seqHash = seqHashIter.next();
522 Sequence sequence = seqMap.get(seqHash);
523 if (sequence != null)
525 grpSeqs.add(sequence);
529 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
530 displayBoxes, displayText, colourText, startRes, endRes);
531 seqGrp.setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
532 colourScheme, seqGrp));
533 seqGrp.setShowNonconserved(showNonconserved);
534 seqGrp.setDescription(description);
535 this.seqGroups.add(seqGrp);
539 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
542 JSONObject alAnnot = alAnnotIter.next();
543 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
544 Annotation[] annotations = new Annotation[annotJsonArray.size()];
546 for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
549 JSONObject annot = annotIter.next();
552 annotations[count] = null;
556 float val = annot.get("value") == null ? null : Float
557 .valueOf(annot.get("value").toString());
558 String desc = annot.get("description") == null ? null : annot
559 .get("description").toString();
560 char ss = annot.get("secondaryStructure") == null
561 || annot.get("secondaryStructure").toString()
562 .equalsIgnoreCase("u0000") ? ' ' : annot
563 .get("secondaryStructure").toString().charAt(0);
564 String displayChar = annot.get("displayCharacter") == null ? ""
565 : annot.get("displayCharacter").toString();
567 annotations[count] = new Annotation(displayChar, desc, ss, val);
568 if (annot.get("colour") != null)
570 Color color = ColorUtils.parseColourString(annot.get(
571 "colour").toString());
572 annotations[count].colour = color;
578 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
579 .get("label").toString(), alAnnot.get("description")
580 .toString(), annotations);
581 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer
582 .valueOf(alAnnot.get("graphType").toString());
584 JSONObject diplaySettings = (JSONObject) alAnnot
585 .get("annotationSettings");
586 if (diplaySettings != null)
589 alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false
590 : Boolean.valueOf(diplaySettings.get("scaleColLabel")
592 alignAnnot.showAllColLabels = (diplaySettings
593 .get("showAllColLabels") == null) ? true : Boolean
594 .valueOf(diplaySettings.get("showAllColLabels")
596 alignAnnot.centreColLabels = (diplaySettings
597 .get("centreColLabels") == null) ? true
598 : Boolean.valueOf(diplaySettings.get("centreColLabels")
600 alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false
601 : Boolean.valueOf(diplaySettings.get("belowAlignment")
603 alignAnnot.visible = (diplaySettings.get("visible") == null) ? true
604 : Boolean.valueOf(diplaySettings.get("visible")
606 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true
607 : Boolean.valueOf(diplaySettings.get("hasIcon")
611 if (alAnnot.get("score") != null)
613 alignAnnot.score = Double
614 .valueOf(alAnnot.get("score").toString());
617 String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get(
618 "calcId").toString();
619 alignAnnot.setCalcId(calcId);
620 String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot
621 .get("sequenceRef").toString() : null;
623 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
624 if (sequence != null)
626 alignAnnot.sequenceRef = sequence;
627 sequence.addAlignmentAnnotation(alignAnnot);
628 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
630 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
632 sequence.addAlignmentAnnotation(alignAnnot);
633 alignAnnot.adjustForAlignment();
636 alignAnnot.validateRangeAndDisplay();
637 this.annotations.add(alignAnnot);
640 } catch (Exception e)
647 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
649 hiddenSeqRefs = new ArrayList<String>();
650 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
651 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
653 String[] seqRefs = hiddenSeqs.split(";");
654 for (String seqRef : seqRefs)
656 hiddenSeqRefs.add(seqRef);
661 public void parseHiddenCols(JSONObject jvSettingsJson)
663 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
664 if (hiddenCols != null && !hiddenCols.isEmpty())
666 columnSelection = new ColumnSelection();
667 String[] rangeStrings = hiddenCols.split(";");
668 for (String rangeString : rangeStrings)
670 String[] range = rangeString.split("-");
671 columnSelection.hideColumns(Integer.valueOf(range[0]),
672 Integer.valueOf(range[1]));
677 @SuppressWarnings("unchecked")
678 private void parseFeatures(JSONArray jsonSeqFeatures)
680 if (jsonSeqFeatures != null)
682 displayedFeatures = new FeaturesDisplayed();
683 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
686 JSONObject jsonFeature = seqFeatureItr.next();
687 Long begin = (Long) jsonFeature.get("xStart");
688 Long end = (Long) jsonFeature.get("xEnd");
689 String type = (String) jsonFeature.get("type");
690 String featureGrp = (String) jsonFeature.get("featureGroup");
691 String descripiton = (String) jsonFeature.get("description");
692 String seqRef = (String) jsonFeature.get("sequenceRef");
693 Float score = Float.valueOf(jsonFeature.get("score").toString());
695 Sequence seq = seqMap.get(seqRef);
696 SequenceFeature sequenceFeature = new SequenceFeature();
697 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
698 if (linksJsonArray != null && linksJsonArray.size() > 0)
700 Iterator<String> linkList = linksJsonArray.iterator();
701 while (linkList.hasNext())
703 String link = linkList.next();
704 sequenceFeature.addLink(link);
707 sequenceFeature.setFeatureGroup(featureGrp);
708 sequenceFeature.setScore(score);
709 sequenceFeature.setDescription(descripiton);
710 sequenceFeature.setType(type);
711 sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
712 sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
713 seq.addSequenceFeature(sequenceFeature);
714 displayedFeatures.setVisible(type);
720 public String getGlobalColourScheme()
722 return globalColourScheme;
725 public void setGlobalColorScheme(String globalColourScheme)
727 this.globalColourScheme = globalColourScheme;
731 public FeaturesDisplayedI getDisplayedFeatures()
733 return displayedFeatures;
736 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
738 this.displayedFeatures = displayedFeatures;
742 public void configureForView(AlignmentViewPanel avpanel)
748 super.configureForView(avpanel);
749 AlignViewportI viewport = avpanel.getAlignViewport();
750 AlignmentI alignment = viewport.getAlignment();
751 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
753 seqGroups = alignment.getGroups();
754 fr = avpanel.cloneFeatureRenderer();
756 // Add non auto calculated annotation to AlignFile
759 for (AlignmentAnnotation annot : annots)
761 if (annot != null && !annot.autoCalculated)
763 annotations.add(annot);
767 globalColourScheme = viewport.getGlobalColourScheme().getSchemeName();
768 setDisplayedFeatures(viewport.getFeaturesDisplayed());
769 showSeqFeatures = viewport.isShowSequenceFeatures();
774 public boolean isShowSeqFeatures()
776 return showSeqFeatures;
779 public void setShowSeqFeatures(boolean showSeqFeatures)
781 this.showSeqFeatures = showSeqFeatures;
784 public Vector<AlignmentAnnotation> getAnnotations()
789 public List<int[]> getHiddenColumns()
791 return hiddenColumns;
795 public ColumnSelection getColumnSelection()
797 return columnSelection;
800 public void setColumnSelection(ColumnSelection columnSelection)
802 this.columnSelection = columnSelection;
806 public SequenceI[] getHiddenSequences()
808 if (hiddenSequences == null || hiddenSequences.isEmpty())
810 return new SequenceI[] {};
812 synchronized (hiddenSequences)
814 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
818 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
820 this.hiddenSequences = hiddenSequences;
823 public class JSONExportSettings
825 private boolean exportSequence;
827 private boolean exportSequenceFeatures;
829 private boolean exportAnnotations;
831 private boolean exportGroups;
833 private boolean exportJalviewSettings;
835 public boolean isExportSequence()
837 return exportSequence;
840 public void setExportSequence(boolean exportSequence)
842 this.exportSequence = exportSequence;
845 public boolean isExportSequenceFeatures()
847 return exportSequenceFeatures;
850 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
852 this.exportSequenceFeatures = exportSequenceFeatures;
855 public boolean isExportAnnotations()
857 return exportAnnotations;
860 public void setExportAnnotations(boolean exportAnnotations)
862 this.exportAnnotations = exportAnnotations;
865 public boolean isExportGroups()
870 public void setExportGroups(boolean exportGroups)
872 this.exportGroups = exportGroups;
875 public boolean isExportJalviewSettings()
877 return exportJalviewSettings;
880 public void setExportJalviewSettings(boolean exportJalviewSettings)
882 this.exportJalviewSettings = exportJalviewSettings;
887 * Returns a descriptor for suitable feature display settings with
889 * <li>ResNums or insertions features visible</li>
890 * <li>insertions features coloured red</li>
891 * <li>ResNum features coloured by label</li>
892 * <li>Insertions displayed above (on top of) ResNums</li>
896 public FeatureSettingsModelI getFeatureColourScheme()
898 return new PDBFeatureSettings();