From: Jim Procter Date: Thu, 19 Feb 2015 15:11:12 +0000 (+0000) Subject: JAL-653 allow dummy sequences to be created if a sequence ID is not found in the... X-Git-Tag: Release_2_10_0~296^2~165 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=1e13e955bb673692c0c122f6a6e3415981a6e64d JAL-653 allow dummy sequences to be created if a sequence ID is not found in the dataset --- 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)