Как избежать исключения циклической зависимости в Spark Scala и заставить код работать с циклической зависимостью - PullRequest
0 голосов
/ 05 апреля 2019

Я получаю исключение ниже в потоке "main"

java.lang.UnsupportedOperationException: cannot have circular references in class, but got the circular reference of class org.det.pia.service.AnalysisCollection
    at org.apache.spark.sql.catalyst.ScalaReflection$.$anonfun$serializerFor$1(ScalaReflection.scala:628)
    at scala.reflect.internal.tpe.TypeConstraints$UndoLog.undo(TypeConstraints.scala:68)
    at org.apache.spark.sql.catalyst.ScalaReflection.cleanUpReflectionObjects(ScalaReflection.scala:906)
    at org.apache.spark.sql.catalyst.ScalaReflection.cleanUpReflectionObjects$(ScalaReflection.scala:905)
    at org.apache.spark.sql.catalyst.ScalaReflection$.cleanUpReflectionObjects(ScalaReflection.scala:46)
    at org.apache.spark.sql.catalyst.ScalaReflection$.serializerFor(ScalaReflection.scala:452)
    at org.apache.spark.sql.catalyst.ScalaReflection$.$anonfun$serializerFor$6(ScalaReflection.scala:644)
    at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:244)
    at scala.collection.immutable.List.foreach(List.scala:392)

Я хочу пропустить это исключение и заставить его работать

scala

  case class FileList( val id: Long, val name: String, val fileName: String, val format: String,
                       val analysisCollection: AnalysisCollection, val analysisProtocolCollection: AnalysisProtocolCollection )

  case class Inputs(val sourceFile:List[SourceFile],val searchDatabase:List[SearchDatabase],val spectraData:List[SpectraData])

  case class AnalysisSoftwareList(val analysisSoftware: List[AnalysisSoftware])

  case class PeptideSpectrumMatch(val id: Long, val charge: Int, val massToCharge: Double,
                                  val deltaMass: Double, val retentionTime: Double, val sequence: String,
                                  val missed: Int, val sourceID: String, val spectrumTitle: String, val pFile: PIAInputFile,
                                  val spectrumID: SpectrumIdentification, val isUnique: Boolean = false,
                                  val isDecoy: Boolean = false, val scores: List[ScoreModel],
                                  val modifications: TreeMap[Integer, Modification], val paramList: List[AbstractParam],
                                  val modificationString: String, val peptideStringID: String, val modificationChanged: Boolean = false,
                                  val identificationKeys: Map[String, String], val peptide: Peptide)

  case class Accession(val id: Long, val accessionStr: String, val files: Set[Long], val descriptions: Map[Long, String],
                       val dbSequence: String, val searchDatabaseRefs: Set[String], val pGroup: Group)

  case class Peptide(val id: Long, val sequence: String, val spectra: List[PeptideSpectrumMatch],
                     val pGroup: Group, val occurrences: HashSet[AccessionOccurrence])

  case class Group(val id: Long, val treeID: Long, val peptides: Map[String, Peptide], val children: TreeMap[Long, Group],
                   val parents: TreeMap[Long, Group],val accessions: Map[String, Accession],
                   val allAccessions: Map[String, Accession])


  case class PiaMergedData(val _date :String,val _name:String, val _ns2:String, val _ns3:String, val filesList: FileList,
                           val inputs: Inputs, val analysisSoftwareList: AnalysisSoftwareList,
                           val spectraList: List[PeptideSpectrumMatch], val accessionsList: List[Accession],
                           val peptidesList: List[Peptide], val groupsList: List[Group]
                          )

  case class AnalysisSoftware(var contactRole: ContactRole, val softwareName:Param, val customizations: String,
                              val version: String,val uri: String)

  case class AnalysisCollection(val spectrumIdentification: List[SpectrumIdentification],
   val proteinDetection: ProteinDetection)

  case class SpectrumIdentification( val inputSpectra: List[InputSpectra], val searchDatabaseRef: List[SearchDatabaseRef],
                                     val spectrumIdentificationProtocolRef: String , val spectrumIdentificationListRef: String,
                                     val spectrumIdentificationList: SpectrumIdentificationList,
                                     val spectrumIdentificationProtocol: SpectrumIdentificationProtocol
  )

  case class InputSpectra(val spectraDataRef: String, val spectraData: SpectraData)

  case class SpectraData(val spectrumIDFormat:SpectrumIDFormat)

  case class SpectrumIDFormat(val cvParam:CvParam)

  case class CvParam(val cvRef: String, val accession: String,val cv: Cv)

  case class Cv(val fullName: String, val version: String, val uri: String, val id: String)

  case class SearchDatabaseRef(val searchDatabaseRef: String, val searchDatabase: SearchDatabase)

  case class SearchDatabase()

  case class SpectrumIdentificationList(val fragmentationTable: FragmentationTable, val spectrumIdentificationResult: List[SpectrumIdentificationResult],
                                        val paramGroup: List[AbstractParam], val numSequencesSearched: Long)

  case class FragmentationTable(val measure: List[Measure])

  case class Measure(val cvParam: List[CvParam])

  case class SpectrumIdentificationResult(val spectrumIdentificationItem: List[SpectrumIdentificationItem],
  val paramGroup: List[AbstractParam], val spectrumID: String, val spectraDataRef: String, val spectraData: SpectraData)

  case class SpectrumIdentificationItem(val peptideEvidenceRef: List[PeptideEvidenceRef], val fragmentation: Fragmentation,
                                       val paramGroup: List[AbstractParam], val chargeState: Int, val experimentalMassToCharge: Double,
                                      val calculatedMassToCharge: Double, val calculatedPI: Float, val peptideRef: String,
                                      val rank: Int, val passThreshold: Boolean = false, val massTableRef: String,
                                      val sampleRef: String, val peptide: Peptide, val massTable: MassTable, val sample: Sample )

  case class PeptideEvidenceRef(val peptideEvidenceRef: String,
  val peptideEvidence: PeptideEvidence)

  case class PeptideEvidence( val paramGroup: List[AbstractParam] , val dbSequenceRef: String ,
                              val peptideRef: String , val start: Integer , val end: Integer ,
  val pre: String , val post: String , val translationTableRef: String , val frame: Integer , val isDecoy: Boolean = false,
  val dbSequence: DBSequence , val peptide: Peptide , val translationTable: TranslationTable )

  case class AbstractParam(val name: String, val value: String, val unitAccession: String, val unitName: String, val unitCvRef: String, val unitCv: Cv)

  case class DBSequence( val paramGroup: List[AbstractParam], val length: Integer,
                         val searchDatabaseRef: String, val accession:String , val searchDatabase: SearchDatabase )

  case class PIAInputFile(val id: Long, val name: String, val fileName: String,
                          val format: String, val analysisCollection: AnalysisCollection, val analysisProtocolCollection: AnalysisProtocolCollection)

  case class AnalysisProtocolCollection(val spectrumIdentificationProtocol: List[SpectrumIdentificationProtocol],
  val proteinDetectionProtocol: ProteinDetectionProtocol
                                       )

  case class ProteinDetection(val inputSpectrumIdentifications: List[InputSpectrumIdentifications],
  val proteinDetectionListRef: String, val proteinDetectionProtocolRef: String, val proteinDetectionList: ProteinDetectionList,
                              val proteinDetectionProtocol: ProteinDetectionProtocol)

Я также добавил тот же класс в Scala ииспользуя его, но получая исключение для этого пакета, поскольку в Java-библиотеке есть циклическая зависимость, которую я не могу изменить, есть ли способ пропустить это исключение?

Java-библиотека работает нормально, но возникает проблема при работе в spark итолько скала

1 Ответ

1 голос
/ 05 апреля 2019
case class Group(val id: Long, val treeID: Long, val peptides: Map[String, Peptide], val children: TreeMap[Long, Group],
                   val parents: TreeMap[Long, Group],val accessions: Map[String, Accession],
                   val allAccessions: Map[String, Accession])

Я бы предложил хранить ссылки на идентификаторы в списках детей и родителей.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...