* Constructor for HMMFile used for exporting
*
* @param hmm
- * @param exportImmediately
*/
public HMMFile(HiddenMarkovModel markov)
{
*/
int nodeNo = 0;
String line = input.readLine();
+ List<HMMNode> nodes = new ArrayList<>();
+
while (line != null && !TERMINATOR.equals(line))
{
HMMNode node = new HMMNode();
- hmm.addNode(node);
+ nodes.add(node);
Scanner scanner = new Scanner(line);
String next = scanner.next();
node.setMatchEmissions(matches);
if (!COMPO.equals(next))
{
- int column = parseAnnotations(scanner, node);
- if (column == 0)
+ int resNo = parseAnnotations(scanner, node);
+ if (resNo == 0)
{
/*
* no MAP annotation provided, just number off from 0 (begin node)
*/
- column = nodeNo;
+ resNo = nodeNo;
}
- hmm.setAlignmentColumn(node, column - 1); // node 1 <==> column 0
+ node.setResidueNumber(resNo);
}
line = input.readLine();
}
nodeNo++;
}
+
+ hmm.setNodes(nodes);
}
/**
* Parses the annotations on the match emission line and add them to the node.
* (See p109 of the HMMER User Guide (V3.1b2) for the specification.) Returns
- * the alignment column number (base 1) that the node maps to, if provided,
- * else zero.
+ * the residue position that the node maps to, if provided, else zero.
*
* @param scanner
* @param node
*/
int parseAnnotations(Scanner scanner, HMMNode node)
{
+ int mapTo = 0;
+
/*
- * map from hmm node to alignment column index, if provided
- * HMM counts columns from 1, convert to base 0 for Jalview
+ * map from hmm node to sequence position, if provided
*/
- int column = 0;
- String value;
if (scanner.hasNext())
{
- value = scanner.next();
+ String value = scanner.next();
if (!"-".equals(value))
{
try
{
- column = Integer.parseInt(value);
- node.setAlignmentColumn(column - 1);
+ mapTo = Integer.parseInt(value);
+ node.setResidueNumber(mapTo);
} catch (NumberFormatException e)
{
// ignore
node.setConsensusStructure(scanner.next().charAt(0));
}
- return column;
+ return mapTo;
}
/**
if (nodeNo != 0)
{
- matchLine += SPACE + (hmm.getNodeAlignmentColumn(nodeNo) + 1);
+ matchLine += SPACE + (hmm.getNodeMapPosition(nodeNo));
matchLine += SPACE + hmm.getConsensusResidue(nodeNo);
matchLine += SPACE + hmm.getReferenceAnnotation(nodeNo);
if (hmm.getFileHeader().contains("HMMER3/f"))
@Override
public SequenceI[] getSeqsAsArray()
{
- SequenceI hmmSeq = hmm.initHMMSequence();
+ SequenceI hmmSeq = hmm.getConsensusSequence();
SequenceI[] seq = new SequenceI[1];
seq[0] = hmmSeq;
return seq;