import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AnnotatedCollectionI;
+import jalview.datamodel.ResidueCount;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
AlignViewportI viewport)
{
List<AnnotatedCollectionI> runBuildFor = new ArrayList<>();
+ boolean foundArg = false;
+
for (ArgumentI arg : params)
{
String name = arg.getName();
if (MessageManager.getString("label.hmmbuild_for").equals(name))
{
+ foundArg = true;
String value = arg.getValue();
+
if (MessageManager.getString("label.alignment").equals(value))
{
- runBuildFor.add(alignment);
+ runBuildFor.add(viewport.getAlignmentView(false)
+ .getVisibleAlignment('-'));
}
else if (MessageManager.getString("label.groups_and_alignment")
.equals(value))
{
- runBuildFor.add(alignment);
+ runBuildFor.add(viewport.getAlignmentView(false)
+ .getVisibleAlignment('-'));
runBuildFor.addAll(viewport.getAlignment().getGroups());
}
else if (MessageManager.getString("label.groups").equals(value))
}
}
}
+
+ /*
+ * default is to build for the whole alignment
+ */
+ if (!foundArg)
+ {
+ runBuildFor.add(alignment);
+ }
+
return runBuildFor;
}
else
{
SequenceI[] sel = ((SequenceGroup) ac)
- .getSelectionAsNewSequences((AlignmentI) ac.getContext());
+ .getSelectionAsNewSequences((AlignmentI) ac.getContext());
for (SequenceI seq : sel)
{
- copy.add(seq);
+ if (seq != null)
+ {
+ copy.add(seq);
+ }
}
}
+ // TODO rather than copy alignment data we should anonymize in situ -
+ // export/File import could use anonymization hash to reinstate references
+ // at import level ?
SequenceI[] copyArray = copy.toArray(new SequenceI[copy.size()]);
Hashtable sequencesHash = stashSequences(copyArray);
boolean ran = runCommand(alignmentFile, hmmFile, ac);
if (!ran)
{
+ JvOptionPane.showInternalMessageDialog(af, MessageManager
+ .formatMessage("warn.command_failed", "hmmbuild"));
return;
}
importData(hmmFile, ac);
}
/**
- * A helper method that deletes any HMM consensus sequence from the given
- * collection, and from the parent alignment if <code>ac</code> is a subgroup
- *
- * @param ac
- */
- void deleteHmmSequences(AnnotatedCollectionI ac)
- {
- SequenceI hmmSeq = ac.getHmmConsensus();
- if (hmmSeq != null)
- {
- if (ac instanceof SequenceGroup)
- {
- ((SequenceGroup) ac).deleteSequence(hmmSeq, false);
- AnnotatedCollectionI context = ac.getContext();
- if (context != null && context instanceof AlignmentI)
- {
- ((AlignmentI) context).deleteSequence(hmmSeq);
- }
- }
- else
- {
- ((AlignmentI) ac).deleteSequence(hmmSeq);
- }
- }
- }
-
- /**
* Constructs and executes the hmmbuild command as a separate process
*
* @param sequencesFile
args.add(ARG_DNA);
}
- args.add(hmmFile.getAbsolutePath());
- args.add(sequencesFile.getAbsolutePath());
+ args.add(getFilePath(hmmFile, true));
+ args.add(getFilePath(sequencesFile, true));
return runCommand(args);
}
new FileParse(hmmFile.getAbsolutePath(), DataSourceType.FILE));
SequenceI hmmSeq = file.getHMM().getConsensusSequence();
+
+
+ ResidueCount counts = new ResidueCount(alignment.getSequences());
+ hmmSeq.getHMM().setBackgroundFrequencies(counts);
+
if (hmmSeq == null)
{
// hmmbuild failure not detected earlier
alignment.insertSequenceAt(topIndex, hmmSeq);
ac.setSeqrep(hmmSeq);
grp.addSequence(hmmSeq, false);
- grp.setHmmConsensus(hmmSeq);
}
else
{
alignment.insertSequenceAt(0, hmmSeq);
- alignment.setHmmConsensus(hmmSeq);
- }
-
- if (af.getSelectedHMM() == null)
- {
- af.setSelectedHMMSequence(hmmSeq);
}
}
}