1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118:
<?php
namespace DispatchModule;
/**
* BaseMatch contains default implementation of some mandatory informations
* - serves only as a helper (reduces code duplicity)
*/
class BaseMatch {
/**
* Human-readable short description (name) of the used alignment tool
* @var string
*/
public $label;
/**
* Matching subsequence of query
* @var string
*/
public $subsequence;
/**
* Starting index of matching subsequence in query
* @var int
*/
public $queryStartPosition;
/**
* Stop index of matching subsequence in query
* @var int
*/
public $queryStopPosition;
/**
* Starting index of matching subsequence in db
* @var int
*/
public $dbStartPosition;
/**
* Stop index of matching subsequence in db
* @var int
*/
public $dbStopPosition;
/**
* List of all scores by the tool in format
* 'scoreName' => 'value'
*
* @var array
*/
public $scores = array();
/**
* Constructor used to save a name of tool
*
* @param string $label
*/
public function __construct($label) {
$this->label = $label;
$this->setCoverage(1);
$this->setIdentity(1);
}
/**
* Sets the coverage of the match i.e. length(match)/length(query)
* @param float $coverage coverage
*/
public function setCoverage($coverage) {
$this->scores["coverage"] = $coverage;
}
/**
* Gets the coverage of the match
* @return int coverage
*/
public function getCoverage() {
return $this->scores["coverage"];
}
/**
* Sets the identity of the match i.e. #hits/length(match)
* @param float $identity identity
*/
public function setIdentity($identity) {
$this->scores["identity"] = $identity;
}
/**
* Gets the identity of the match
* @return int identity
*/
public function getIdentity() {
return $this->scores["identity"];
}
/**
* Gets the bit-score of the match
* @return int bit-score
*/
public function getScore() {
if (is_null($this->scores["identity"]) || empty($this->scores["identity"])) {
if (is_null($this->scores["coverage"]) || empty($this->scores["coverage"])) {
return 1;
} else {
return $this->scores["coverage"];
}
} else if (is_null($this->scores["coverage"]) || empty($this->scores["coverage"])) {
return $this->scores["identity"];
} else {
return $this->scores["coverage"] * $this->scores["identity"];
}
}
}