Skip to content

Commit

Permalink
small old fixes for errors in mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
sunbrn committed Jan 22, 2019
1 parent 74ad3a3 commit 037b41e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/it/polimi/genomics/metadata/cleaner/Rule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ case class Rule(antecedent: String, consequent: String) extends PartiallyOrdered
if (that.isInstanceOf[Rule]) {
val thatIns = that.asInstanceOf[Rule]

val autoThis = new RegExp(this.antecedent).toAutomaton()
val autoThis = new RegExp(this.antecedent).toAutomaton() //autoThis = existing
autoThis.expandSingleton()
//autoThis.determinize()

val autoThat = new RegExp(thatIns.antecedent).toAutomaton()
val autoThat = new RegExp(thatIns.antecedent).toAutomaton() //autoThat = newRule
autoThat.expandSingleton()
//autoThat.determinize()

Expand All @@ -31,10 +31,10 @@ case class Rule(antecedent: String, consequent: String) extends PartiallyOrdered
//val inter = BasicOperations.intersection(autoThis, autoThat)
//inter.determinize()
//if (inter.equals(autoThat)) //L(a') is contained in L(a) (new is contained in existing)
if (autoThat.subsetOf(autoThis))
if (autoThat.subsetOf(autoThis)) //existing contains newRule = 1
Some(1)
//else if (inter.equals(autoThis)) //L(a) is contained in L(a') (existing is contained in new)
else if (autoThis.subsetOf(autoThat))
else if (autoThis.subsetOf(autoThat)) // existing is contained in newRule = -1
Some(-1)
else {
val inter = BasicOperations.intersection(autoThis, autoThat)
Expand Down
12 changes: 9 additions & 3 deletions src/main/scala/it/polimi/genomics/metadata/mapper/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ object main {
val bioSampleList = new REP.Utils.BioSampleList(old_lines.toArray, repTableId)

//in files with simple epi__donor_id, it adds the keys epi__donor_id__X for each biosample present (same for other attributes)
val lines = enrichLinesREP(old_lines.toArray, bioSampleList)
val lines = enrichLinesREP(old_lines.toArray, bioSampleList,path)

//prepares ficticious replicate tuples (id=biosample_id, bio/tech replicate number = 1)
val replicateList = new REP.Utils.ReplicateList(lines, bioSampleList)
Expand Down Expand Up @@ -479,7 +479,7 @@ object main {
states
}

def enrichLinesREP(lines: Array[String], bioSampleList: REP.Utils.BioSampleList): Array[String] = {
def enrichLinesREP(lines: Array[String], bioSampleList: REP.Utils.BioSampleList,path:String): Array[String] = {
val bioNumbers = 1 to bioSampleList.BiosampleList.length toList
var linesFromSet = scala.collection.mutable.Set(lines: _*) //transform array into set
for (l <- linesFromSet.toList) {
Expand Down Expand Up @@ -532,7 +532,7 @@ object main {
None
else
None
}.flatten.head
}.flatten.headOption.getOrElse("Error during EnrichLinesREP method")

val hasDonorId = linesFromSet.toList.map{l=>
val pair = l.split("\t", 2)
Expand Down Expand Up @@ -564,6 +564,12 @@ object main {
linesFromSet += "epi__sample_alias__1" + "\t" + manCurId


//useful for tads which do not have a file name
val str : Array[String] = path.split("/")
val file_name: String = str.last.split("\\.").head
linesFromSet += "file_name" + "\t" + file_name


linesFromSet.toArray
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BioSampleREP(repTableId: REPTableId, quantity: Int) extends REPTable(repTa
this.insertPosition = resetPosition(this.insertPosition, quantity)
}
case "TYPES" => {
param match{
param match {
case "PrimaryCell" => this.typesArray(typesInsertPosition) = insertMethod(this.typesArray(typesInsertPosition), "Primary cell")
case "PrimaryTissue" => this.typesArray(typesInsertPosition) = insertMethod(this.typesArray(typesInsertPosition), "Primary tissue")
case "ESCDerived" => this.typesArray(typesInsertPosition) = insertMethod(this.typesArray(typesInsertPosition), "ESC derived cell line")
Expand All @@ -66,14 +66,14 @@ class BioSampleREP(repTableId: REPTableId, quantity: Int) extends REPTable(repTa
}

case "TISSUE" => {
if (typesArray(tissueInsertPosition) == null || typesArray(tissueInsertPosition).toLowerCase.contains("tissue"))
this.tissueArray(tissueInsertPosition) = insertMethod(this.tissueArray(tissueInsertPosition), param)
else
this.tissueArray(tissueInsertPosition) = null
// if (typesArray(tissueInsertPosition) == null || typesArray(tissueInsertPosition).toLowerCase.contains("tissue"))
this.tissueArray(tissueInsertPosition) = insertMethod(this.tissueArray(tissueInsertPosition), param)
// else
// this.tissueArray(tissueInsertPosition) = null
this.tissueInsertPosition = resetPosition(this.tissueInsertPosition, quantity)
}
case "CELLLINE" => {
if (typesArray(tissueInsertPosition) == null || typesArray(tissueInsertPosition).toLowerCase.contains("tissue"))
if (typesArray(tissueInsertPosition) == null || typesArray(tissueInsertPosition).toLowerCase.contains("tissue"))
this.cellLineArray(cellLineInsertPosition) = null
else
this.cellLineArray(cellLineInsertPosition) = insertMethod(this.cellLineArray(cellLineInsertPosition), param)
Expand All @@ -85,7 +85,7 @@ class BioSampleREP(repTableId: REPTableId, quantity: Int) extends REPTable(repTa
}
case "DISEASE" => {
val a: String = this.disease.getOrElse(null)
val b: String = insertMethod(a,param)
val b: String = insertMethod(a, param)
this.diseaseArray(diseaseInsertPosition) = Some(b)
this.diseaseInsertPosition = resetPosition(diseaseInsertPosition, quantity)
}
Expand Down

0 comments on commit 037b41e

Please sign in to comment.