comparison COBRAxy/marea.py @ 283:2436856c7e51 draft

Uploaded
author francesco_lapi
date Tue, 13 May 2025 09:06:31 +0000
parents f5635309779a
children 2febf79bb334
comparison
equal deleted inserted replaced
282:f5635309779a 283:2436856c7e51
433 433
434 def styleReactionElements(self, metabMap :ET.ElementTree, reactionId :str, *, mindReactionDir = True) -> None: 434 def styleReactionElements(self, metabMap :ET.ElementTree, reactionId :str, *, mindReactionDir = True) -> None:
435 # If We're dealing with RAS data or in general don't care about the direction of the reaction we only style the arrow body 435 # If We're dealing with RAS data or in general don't care about the direction of the reaction we only style the arrow body
436 if not mindReactionDir: 436 if not mindReactionDir:
437 return self.applyTo(getArrowBodyElementId(reactionId), metabMap, self.toStyleStr()) 437 return self.applyTo(getArrowBodyElementId(reactionId), metabMap, self.toStyleStr())
438 print('PROVA 1')
439 # Now we style the arrow head(s): 438 # Now we style the arrow head(s):
440 idOpt1, idOpt2 = getArrowHeadElementId(reactionId) 439 idOpt1, idOpt2 = getArrowHeadElementId(reactionId)
440 print(f'{idOpt1} {self.toStyleStr(downSizedForTips = True)}')
441 if idOpt2: print(f'{idOpt2} {self.toStyleStr(downSizedForTips = True)}')
442 print('----')
441 self.applyTo(idOpt1, metabMap, self.toStyleStr(downSizedForTips = True)) 443 self.applyTo(idOpt1, metabMap, self.toStyleStr(downSizedForTips = True))
442 if idOpt2: self.applyTo(idOpt2, metabMap, self.toStyleStr(downSizedForTips = True)) 444 if idOpt2: self.applyTo(idOpt2, metabMap, self.toStyleStr(downSizedForTips = True))
443 445
444 def getMapReactionId(self, reactionId :str, mindReactionDir :bool) -> str: 446 def getMapReactionId(self, reactionId :str, mindReactionDir :bool) -> str:
445 """ 447 """
497 if math.isnan(pValue) or (isinstance(foldChange, float) and math.isnan(foldChange)): continue 499 if math.isnan(pValue) or (isinstance(foldChange, float) and math.isnan(foldChange)): continue
498 500
499 if isinstance(foldChange, str): foldChange = float(foldChange) 501 if isinstance(foldChange, str): foldChange = float(foldChange)
500 if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow 502 if pValue >= ARGS.pValue: # pValue above tresh: dashed arrow
501 INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId) 503 INSIGNIFICANT_ARROW.styleReactionElements(metabMap, reactionId)
502 print('PROVA 2')
503 continue 504 continue
504 505
505 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1): 506 if abs(foldChange) < (ARGS.fChange - 1) / (abs(ARGS.fChange) + 1):
506 INVALID_ARROW.styleReactionElements(metabMap, reactionId) 507 INVALID_ARROW.styleReactionElements(metabMap, reactionId)
508 print('Prova 2')
507 continue 509 continue
508 510
509 width = Arrow.MAX_W 511 width = Arrow.MAX_W
510 if not math.isinf(foldChange): 512 if not math.isinf(foldChange):
511 try: width = max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W) 513 try: width = max(abs(z_score * Arrow.MAX_W) / maxNumericZScore, Arrow.MIN_W)
524 # If the score is 1 (opposite signs) we use alternative colors vvv 526 # If the score is 1 (opposite signs) we use alternative colors vvv
525 arrow = Arrow(width, ArrowColor.fromFoldChangeSign(foldChange, useAltColor = inversionScore == 1)) 527 arrow = Arrow(width, ArrowColor.fromFoldChangeSign(foldChange, useAltColor = inversionScore == 1))
526 528
527 # vvv These 2 if statements can both be true and can both happen 529 # vvv These 2 if statements can both be true and can both happen
528 if ARGS.net: # style arrow head(s): 530 if ARGS.net: # style arrow head(s):
531 print('Prova NET')
529 arrow.styleReactionElements(metabMap, reactionId + ("_B" if inversionScore == 2 else "_F")) 532 arrow.styleReactionElements(metabMap, reactionId + ("_B" if inversionScore == 2 else "_F"))
530 533
531 if not ARGS.using_RAS: # style arrow body 534 if not ARGS.using_RAS: # style arrow body
532 arrow.styleReactionElements(metabMap, reactionId, mindReactionDir = False) 535 arrow.styleReactionElements(metabMap, reactionId, mindReactionDir = False)
533 536