From 1e13e955bb673692c0c122f6a6e3415981a6e64d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 19 Feb 2015 15:11:12 +0000 Subject: [PATCH] JAL-653 allow dummy sequences to be created if a sequence ID is not found in the dataset --- src/jalview/datamodel/SequenceDummy.java | 9 +++++++++ src/jalview/io/FeaturesFile.java | 25 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/jalview/datamodel/SequenceDummy.java diff --git a/src/jalview/datamodel/SequenceDummy.java b/src/jalview/datamodel/SequenceDummy.java new file mode 100644 index 0000000..80b0072 --- /dev/null +++ b/src/jalview/datamodel/SequenceDummy.java @@ -0,0 +1,9 @@ +package jalview.datamodel; + +public class SequenceDummy extends Sequence implements SequenceI +{ + public SequenceDummy(String sequenceId) + { + super(sequenceId, "THISAPLACEHOLDER"); + } +} diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 2001d7f..2009d9d 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -169,6 +169,10 @@ public class FeaturesFile extends AlignFile try { SequenceI seq = null; + /** + * keep track of any sequences we try to create from the data if it is a GFF3 file + */ + ArrayList newseqs = new ArrayList(); String type, desc, token = null; int index, start, end; @@ -442,7 +446,7 @@ public class FeaturesFile extends AlignFile // Still possible this is an old Jalview file, // which does not have type colours at the beginning seqId = token = st.nextToken(); - seq = findName(align, seqId, relaxedIdmatching); + seq = findName(align, seqId, relaxedIdmatching, newseqs); if (seq != null) { desc = st.nextToken(); @@ -551,7 +555,7 @@ public class FeaturesFile extends AlignFile if (!token.equals("ID_NOT_SPECIFIED")) { - seq = findName(align, seqId = token, relaxedIdmatching); + seq = findName(align, seqId = token, relaxedIdmatching, null); st.nextToken(); } else @@ -647,7 +651,7 @@ public class FeaturesFile extends AlignFile } private SequenceI findName(AlignmentI align, String seqId, - boolean relaxedIdMatching) + boolean relaxedIdMatching, List newseqs) { SequenceI match = null; if (relaxedIdMatching) @@ -656,16 +660,29 @@ public class FeaturesFile extends AlignFile { matcher = new SequenceIdMatcher( (lastmatchedAl = align).getSequencesArray()); + if (newseqs != null) + { + matcher.addAll(newseqs); + } } match = matcher.findIdMatch(seqId); } else { match = align.findName(seqId, true); + + } + if (match==null && newseqs!=null) + { + match = new SequenceDummy(seqId); + if (relaxedIdMatching) + { + matcher.addAll(Arrays.asList(new SequenceI[] + { match })); + } } return match; } - public void parseDescriptionHTML(SequenceFeature sf, boolean removeHTML) { if (sf.getDescription() == null) -- 1.7.10.2