List of usage examples for org.apache.commons.collections CollectionUtils intersection
public static Collection intersection(final Collection a, final Collection b)
From source file:ru.ksu.niimm.cll.mocassin.util.GraphMetricUtils.java
/** * this method computes Jaccard coefficient for neighbors of a given pair of * structural elements// w w w . ja v a 2s. c o m */ public static float computeNeighborJaccard(Collection<?> iNeighbors, Collection<?> jNeighbors) { int intersection = CollectionUtils.intersection(iNeighbors, jNeighbors).size(); int union = CollectionUtils.union(iNeighbors, jNeighbors).size(); float jaccard = (float) intersection / union; return jaccard; }
From source file:services.pet.MountService.java
private void callVehicle(CreatureObject actor, SWGObject pcd, PlayerObject player, CreatureObject mount) { if ((mount.getLevel() - actor.getLevel()) > 5) { actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_level"), DisplayType.Broadcast); return;/* w w w .ja v a 2 s . c o m*/ } // FIXME Movement skillmod should always be used instead of CREO4 speed vars directly. Movement skillmod should NEVER be 0 unless rooted. Currently it is, which is wrong. //if (actor.getSkillModBase("movement") == 0) { //actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_vehicle_rooted"), DisplayType.Broadcast); //return; //} if (actor.getPlanet().getName().contains("kashyyyk") && !actor.getPlanet().getName().contains("_main")) { actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:vehicle_restricted_scene"), DisplayType.Broadcast); //mount_restricted_scene for creature mounts return; } if (player.isCallingCompanion()) { actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:cant_call_1sec"), DisplayType.Broadcast); return; } core.petService.storeAll(actor); storeAll(actor); player.setCallingCompanion(true); if (actor.getTefTime() > 0) { actor.sendSystemMessage(OutOfBand.ProsePackage("@pet/pet_menu:call_vehicle_delay", actor.getTefTime()), DisplayType.Broadcast); } try { while (actor.getTefTime() > 0) { Thread.sleep(3000); } } catch (InterruptedException e) { e.printStackTrace(); } SWGObject datapad = actor.getSlottedObject("datapad"); if (datapad == null) { return; } datapad.viewChildren(actor, false, false, new Traverser() { public void process(SWGObject pcd) { if (pcd.getAttachment("companionId") != null && mount.getObjectID() == ((Long) pcd.getAttachment("companionId"))) { if (pcd.getSlottedObject("inventory") != null) { LongAdder adder = new LongAdder(); pcd.getSlottedObject("inventory").viewChildren(actor, false, false, (obj) -> adder.increment()); if (adder.intValue() == 1) { pcd.getSlottedObject("inventory").remove(mount); mount.setPosition(actor.getPosition().clone()); mount.setOrientation(actor.getOrientation().clone()); mount.setPlanet(actor.getPlanet()); DevLog.debugout("Charon", "Mount Service", "PROCESS MOUNT " + mount.getTemplate()); core.simulationService.add(mount, actor.getWorldPosition().x, actor.getWorldPosition().z, false); } } } } }); player.setCallingCompanion(false); // Make the vehicle visible List<SWGObject> newAwareObjects = core.simulationService.get(actor.getPlanet(), actor.getWorldPosition().x, actor.getWorldPosition().z, 512); ArrayList<SWGObject> oldAwareObjects = new ArrayList<SWGObject>(actor.getAwareObjects()); @SuppressWarnings("unchecked") Collection<SWGObject> updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); for (int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); //System.out.println(obj.getTemplate()); if (!updateAwareObjects.contains(obj) && obj != actor && !actor.getAwareObjects().contains(obj) && obj.getContainer() != actor && obj.isInQuadtree()) { if (obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance2D(actor.getWorldPosition()) > 200) continue; actor.makeAware(obj); if (obj.getClient() != null) obj.makeAware(actor); } } }
From source file:services.SimulationService.java
@Override public void insertOpcodes(Map<Integer, INetworkRemoteEvent> swgOpcodes, Map<Integer, INetworkRemoteEvent> objControllerOpcodes) { objControllerOpcodes.put(ObjControllerOpcodes.DATA_TRANSFORM, new INetworkRemoteEvent() { @Override/*from w w w . ja va 2s . c om*/ public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); DataTransform dataTransform = new DataTransform(); dataTransform.deserialize(data); //System.out.println("Movement Counter: " + dataTransform.getMovementCounter()); Client client = core.getClient(session); if (client == null) { System.out.println("NULL Client"); return; } if (client.getParent() == null) { System.out.println("NULL Object"); return; } CreatureObject creature = (CreatureObject) client.getParent(); if (creature.getPosture() == Posture.Dead || creature.getPosture() == Posture.Incapacitated) return; CreatureObject object = creature; if (core.mountService.isMounted(creature) && creature.getObjectID() == ((CreatureObject) creature.getContainer()).getOwnerId()) { object = (CreatureObject) object.getContainer(); } Point3D newPos; Point3D oldPos; synchronized (object.getMutex()) { newPos = new Point3D(dataTransform.getXPosition(), dataTransform.getYPosition(), dataTransform.getZPosition()); if (Float.isNaN(newPos.x) || Float.isNaN(newPos.y) || Float.isNaN(newPos.z)) return; oldPos = object.getPosition(); } if (object instanceof CreatureObject && object.getOption(Options.MOUNT)) { if (!checkLineOfSight(object, newPos)) { newPos = oldPos; } } synchronized (object.getMutex()) { //Collection<Client> oldObservers = object.getObservers(); //Collection<Client> newObservers = new HashSet<Client>(); if (object.getContainer() == null) move(object, oldPos.x, oldPos.z, newPos.x, newPos.z); Quaternion newOrientation = new Quaternion(dataTransform.getWOrientation(), dataTransform.getXOrientation(), dataTransform.getYOrientation(), dataTransform.getZOrientation()); object.setPosition(newPos); creature.setPosition(newPos); object.setOrientation(newOrientation); creature.setOrientation(newOrientation); object.setMovementCounter(dataTransform.getMovementCounter()); creature.setMovementCounter(dataTransform.getMovementCounter()); } synchronized (creature.getMutex()) { if (dataTransform.getSpeed() > 0.0f) { switch (creature.getLocomotion()) { case Locomotion.Prone: creature.setLocomotion(Locomotion.Crawling); break; case Locomotion.ClimbingStationary: creature.setLocomotion(Locomotion.Climbing); break; case Locomotion.Standing: case Locomotion.Running: case Locomotion.Walking: if (dataTransform.getSpeed() >= (creature.getRunSpeed() * (creature.getSpeedMultiplierBase() + creature.getSpeedMultiplierMod()))) { creature.setLocomotion(Locomotion.Running); } else { creature.setLocomotion(Locomotion.Walking); } break; case Locomotion.Sneaking: case Locomotion.CrouchSneaking: case Locomotion.CrouchWalking: if (dataTransform.getSpeed() >= (creature.getRunSpeed() * (creature.getSpeedMultiplierBase() + creature.getSpeedMultiplierMod()))) { creature.setLocomotion(Locomotion.CrouchSneaking); } else { creature.setLocomotion(Locomotion.CrouchWalking); } break; } } else { switch (creature.getLocomotion()) { case Locomotion.Crawling: creature.setLocomotion(Locomotion.Prone); break; case Locomotion.Climbing: creature.setLocomotion(Locomotion.ClimbingStationary); break; case Locomotion.Running: case Locomotion.Walking: creature.setLocomotion(Locomotion.Standing); break; case Locomotion.CrouchSneaking: case Locomotion.CrouchWalking: creature.setLocomotion(Locomotion.Sneaking); break; } } } if (object.getContainer() != null) { object.getContainer()._remove(object); add(object, newPos.x, newPos.z); } //object.setParentId(0); //object.setParent(null); // System.out.println("Parsed Height: " + core.terrainService.getHeight(object.getPlanetId(), dataTransform.getXPosition(), dataTransform.getZPosition()) // + " should be: " + dataTransform.getYPosition()); UpdateTransformMessage utm = new UpdateTransformMessage(object.getObjectID(), dataTransform.getTransformedX(), dataTransform.getTransformedY(), dataTransform.getTransformedZ(), dataTransform.getMovementCounter(), (byte) dataTransform.getMovementAngle(), dataTransform.getSpeed()); object.notifyObservers(utm, false); List<SWGObject> newAwareObjects = get(creature.getPlanet(), newPos.x, newPos.z, 512); ArrayList<SWGObject> oldAwareObjects = new ArrayList<SWGObject>(creature.getAwareObjects()); @SuppressWarnings("unchecked") Collection<SWGObject> updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); for (int i = 0; i < oldAwareObjects.size(); i++) { SWGObject obj = oldAwareObjects.get(i); if (!updateAwareObjects.contains(obj) && obj != creature && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() /*&& obj.getParentId() == 0*/) { if (obj.getAttachment("bigSpawnRange") != null && obj.getWorldPosition().getDistance2D(newPos) < 512) continue; creature.makeUnaware(obj); if (obj.getClient() != null) obj.makeUnaware(creature); } else if (obj != creature && obj.getWorldPosition().getDistance2D(newPos) > 200 && obj.isInQuadtree() && obj.getAttachment("bigSpawnRange") == null) { creature.makeUnaware(obj); if (obj.getClient() != null) obj.makeUnaware(creature); } } for (int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); //System.out.println(obj.getTemplate()); if (!updateAwareObjects.contains(obj) && obj != creature && !creature.getAwareObjects().contains(obj) && obj.getContainer() != creature && obj.isInQuadtree()) { if (obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance2D(newPos) > 200) continue; creature.makeAware(obj); if (obj.getClient() != null) obj.makeAware(creature); } } checkForCollidables(object); object.setAttachment("lastValidPosition", object.getPosition()); MoveEvent event = new MoveEvent(); event.object = object; object.getEventBus().publish(event); } }); objControllerOpcodes.put(ObjControllerOpcodes.DATA_TRANSFORM_WITH_PARENT, new INetworkRemoteEvent() { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); DataTransformWithParent dataTransform = new DataTransformWithParent(); dataTransform.deserialize(data); Client client = core.getClient(session); if (core.objectService.getObject(dataTransform.getCellId()) == null) return; SWGObject parent = core.objectService.getObject(dataTransform.getCellId()); if (client == null) { System.out.println("NULL Client"); return; } if (client.getParent() == null) { System.out.println("NULL Object"); return; } CreatureObject object = (CreatureObject) client.getParent(); if (object.getPosture() == Posture.Dead || object.getPosture() == Posture.Incapacitated) return; if (core.mountService.isMounted(object)) { object.sendSystemMessage(OutOfBand.ProsePackage("@pet_menu:cant_mount"), DisplayType.Broadcast); core.mountService.dismount(object, (CreatureObject) object.getContainer()); } Point3D newPos = new Point3D(dataTransform.getXPosition(), dataTransform.getYPosition(), dataTransform.getZPosition()); newPos.setCell((CellObject) parent); if (Float.isNaN(newPos.x) || Float.isNaN(newPos.y) || Float.isNaN(newPos.z)) return; Point3D oldPos = object.getPosition(); Quaternion newOrientation = new Quaternion(dataTransform.getWOrientation(), dataTransform.getXOrientation(), dataTransform.getYOrientation(), dataTransform.getZOrientation()); UpdateTransformWithParentMessage utm = new UpdateTransformWithParentMessage(object.getObjectID(), dataTransform.getCellId(), dataTransform.getTransformedX(), dataTransform.getTransformedY(), dataTransform.getTransformedZ(), dataTransform.getMovementCounter(), (byte) dataTransform.getMovementAngle(), dataTransform.getSpeed()); if (object.getContainer() != parent) { remove(object, oldPos.x, oldPos.z); if (object.getContainer() != null) object.getContainer()._remove(object); if (object.getClient() == null) System.err.println("Client is null! This is a very strange error."); //if (object.getClient() != null && object.getClient().isGM() && parent != null && parent instanceof CellObject && parent.getContainer() != null) //object.sendSystemMessage("BuildingId - Dec: " + parent.getContainer().getObjectID() + " Hex: " + Long.toHexString(parent.getContainer().getObjectID()) + " CellNumber: " + ((CellObject) parent).getCellNumber(), DisplayType.Broadcast); parent._add(object); } object.setPosition(newPos); object.setOrientation(newOrientation); object.setMovementCounter(dataTransform.getMovementCounter()); object.notifyObservers(utm, false); checkForCollidables(object); object.setAttachment("lastValidPosition", object.getPosition()); synchronized (object.getMutex()) { if (dataTransform.getSpeed() > 0.0f) { switch (object.getLocomotion()) { case Locomotion.Prone: object.setLocomotion(Locomotion.Crawling); break; case Locomotion.ClimbingStationary: object.setLocomotion(Locomotion.Climbing); break; case Locomotion.Standing: case Locomotion.Running: case Locomotion.Walking: if (dataTransform.getSpeed() >= (object.getRunSpeed() * (object.getSpeedMultiplierBase() + object.getSpeedMultiplierMod()))) { object.setLocomotion(Locomotion.Running); } else { object.setLocomotion(Locomotion.Walking); } break; case Locomotion.Sneaking: case Locomotion.CrouchSneaking: case Locomotion.CrouchWalking: if (dataTransform.getSpeed() >= (object.getRunSpeed() * (object.getSpeedMultiplierBase() + object.getSpeedMultiplierMod()))) { object.setLocomotion(Locomotion.CrouchSneaking); } else { object.setLocomotion(Locomotion.CrouchWalking); } break; } } else { switch (object.getLocomotion()) { case Locomotion.Crawling: object.setLocomotion(Locomotion.Prone); break; case Locomotion.Climbing: object.setLocomotion(Locomotion.ClimbingStationary); break; case Locomotion.Running: case Locomotion.Walking: object.setLocomotion(Locomotion.Standing); break; case Locomotion.CrouchSneaking: case Locomotion.CrouchWalking: object.setLocomotion(Locomotion.Sneaking); break; } } } } }); swgOpcodes.put(Opcodes.ClientOpenContainerMessage, new INetworkRemoteEvent() { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { System.out.println("Open Container Request"); } }); objControllerOpcodes.put(ObjControllerOpcodes.lookAtTarget, new INetworkRemoteEvent() { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); Client client = core.getClient(session); if (client == null) { System.out.println("NULL Client"); return; } if (client.getParent() == null) { System.out.println("NULL Object"); return; } CreatureObject object = (CreatureObject) client.getParent(); TargetUpdate targetUpdate = new TargetUpdate(); targetUpdate.deserialize(data); object.setLookAtTarget(targetUpdate.getTargetId()); } }); objControllerOpcodes.put(ObjControllerOpcodes.intendedTarget, new INetworkRemoteEvent() { @Override public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); Client client = core.getClient(session); if (client == null) { System.out.println("NULL Client"); return; } if (client.getParent() == null) { System.out.println("NULL Object"); return; } CreatureObject object = (CreatureObject) client.getParent(); TargetUpdate targetUpdate = new TargetUpdate(); targetUpdate.deserialize(data); object.setIntendedTarget(targetUpdate.getTargetId()); } }); }
From source file:services.SimulationService.java
public void moveObject(SWGObject object, Point3D newPosition, Quaternion newOrientation, int movementCounter, float speed, CellObject cell) { if (Float.isNaN(newPosition.x) || Float.isNaN(newPosition.y) || Float.isNaN(newPosition.z)) return;//www .jav a 2s.c o m if (object instanceof CreatureObject) { CreatureObject cre = (CreatureObject) object; if (cre.getPosture() == Posture.Dead || cre.getPosture() == Posture.Incapacitated) return; } if (cell == null) { Point3D oldPos; synchronized (object.getMutex()) { oldPos = object.getPosition(); if (object.getContainer() == null) move(object, oldPos.x, oldPos.z, newPosition.x, newPosition.z); object.setPosition(newPosition); object.setOrientation(newOrientation); object.setMovementCounter(movementCounter + 1); } if (object.getContainer() != null && newPosition != oldPos) { object.getContainer()._remove(object); add(object, newPosition.x, newPosition.z); } if (object.getPlanet().getName().equals("talus") && object.getTemplate().contains("stormtrooper")) { // float xx = object.getWorldPosition().x - newPosition.x; // float zz = object.getWorldPosition().z - newPosition.z; // float diff = (float) Math.sqrt(xx*xx+zz*zz); // System.out.println(" ((CreatureObject)object).getSpeedMultiplierBase());: " + ((CreatureObject)object).getSpeedMultiplierBase()); // System.out.println(" ((CreatureObject)object).getSpeedMultiplierMod());: " + ((CreatureObject)object).getSpeedMultiplierMod()); // } UpdateTransformMessage utm = new UpdateTransformMessage(object.getObjectID(), (short) (newPosition.x * 4 + 0.5), (short) (newPosition.y * 4 + 0.5), (short) (newPosition.z * 4 + 0.5), movementCounter + 1, getSpecialDirection(newOrientation), speed); List<SWGObject> newAwareObjects = get(object.getPlanet(), newPosition.x, newPosition.z, 512); ArrayList<SWGObject> oldAwareObjects = new ArrayList<SWGObject>(object.getAwareObjects()); @SuppressWarnings("unchecked") Collection<SWGObject> updateAwareObjects = CollectionUtils.intersection(oldAwareObjects, newAwareObjects); object.notifyObservers(utm, false); for (int i = 0; i < oldAwareObjects.size(); i++) { SWGObject obj = oldAwareObjects.get(i); if (!updateAwareObjects.contains(obj) && obj != object && obj.getWorldPosition().getDistance2D(newPosition) > 200 && obj.isInQuadtree() /*&& obj.getParentId() == 0*/) { if (obj.getAttachment("bigSpawnRange") != null && obj.getWorldPosition().getDistance2D(newPosition) < 512) continue; object.makeUnaware(obj); if (obj.getClient() != null) obj.makeUnaware(object); } else if (obj != object && obj.getWorldPosition().getDistance2D(newPosition) > 200 && obj.isInQuadtree() && obj.getAttachment("bigSpawnRange") == null) { object.makeUnaware(obj); if (obj.getClient() != null) obj.makeUnaware(object); } } for (int i = 0; i < newAwareObjects.size(); i++) { SWGObject obj = newAwareObjects.get(i); //System.out.println(obj.getTemplate()); if (!updateAwareObjects.contains(obj) && obj != object && !object.getAwareObjects().contains(obj) && obj.getContainer() != object && obj.isInQuadtree()) { if (obj.getAttachment("bigSpawnRange") == null && obj.getWorldPosition().getDistance2D(newPosition) > 200) continue; object.makeAware(obj); if (obj.getClient() != null) obj.makeAware(object); } } checkForCollidables(object); MoveEvent event = new MoveEvent(); event.object = object; object.getEventBus().publish(event); } else { newPosition.setCell(cell); Point3D oldPos = object.getPosition(); object.setPosition(newPosition); object.setOrientation(newOrientation); object.setMovementCounter(movementCounter + 1); UpdateTransformWithParentMessage utm = new UpdateTransformWithParentMessage(object.getObjectID(), cell.getObjectID(), (short) (newPosition.x * 8 + 0.5), (short) (newPosition.y * 8 + 0.5), (short) (newPosition.z * 8 + 0.5), movementCounter + 1, getSpecialDirection(newOrientation), speed); if (object.getContainer() != cell) { remove(object, oldPos.x, oldPos.z); if (object.getContainer() != null) object.getContainer()._remove(object); cell._add(object); } object.notifyObservers(utm, false); checkForCollidables(object); } }
From source file:uk.ac.ebi.intact.util.protein.ProteinServiceImpl.java
/** * Update an existing intact protein's annotations. * <p/>//from w w w.j av a 2s . c o m * That includes, all Xrefs, Aliases, splice variants. * * @param protein the intact protein to update. * @param uniprotProtein the uniprot protein used for data input. */ private void updateProtein(Protein protein, UniprotProtein uniprotProtein) throws ProteinServiceException { List<Protein> proteins = new ArrayList<Protein>(); // check that both protein carry the same organism information if (!UpdateBioSource(protein, uniprotProtein.getOrganism())) { return; } // Fullname String fullname = uniprotProtein.getDescription(); if (fullname != null && fullname.length() > 250) { if (log.isDebugEnabled()) { log.debug("Truncating fullname to the first 250 first chars."); } fullname = fullname.substring(0, 250); } protein.setFullName(fullname); // Shortlabel protein.setShortLabel(generateProteinShortlabel(uniprotProtein)); // Xrefs -- but UniProt's as they are supposed to be up-to-date at this stage. XrefUpdaterReport reports = XrefUpdaterUtils.updateAllXrefs(protein, uniprotProtein, databaseName2mi, IntactContext.getCurrentInstance().getDataContext(), processor, new TreeSet<InteractorXref>(new InteractorXrefComparator()), new TreeSet<UniprotXref>(new UniprotXrefComparator(databaseName2mi))); uniprotServiceResult.addXrefUpdaterReport(reports); // Aliases AliasUpdaterUtils.updateAllAliases(protein, uniprotProtein, IntactContext.getCurrentInstance().getDataContext(), processor); // Sequence updateProteinSequence(protein, uniprotProtein.getSequence(), uniprotProtein.getCrc64()); // Persist changes DaoFactory daoFactory = IntactContext.getCurrentInstance().getDataContext().getDaoFactory(); ProteinDao pdao = daoFactory.getProteinDao(); pdao.update((ProteinImpl) protein); /////////////////////////////// // Update Splice Variants and feature chains // search intact // splice variants with no 'no-uniprot-update' Collection<ProteinImpl> spliceVariantsAndChains = pdao.getSpliceVariants(protein); // feature chains spliceVariantsAndChains.addAll(pdao.getProteinChains(protein)); // We create a copy of the collection that hold the protein transcripts as the findMatches remove the protein transcripts // from the collection when a match is found. Therefore the first time it runs, it finds the match, protein transcripts // are correctly created, the protein transcripts are deleted from the collection so that the second // you run it, the splice variant are not linked anymore to the uniprotProtein and therefore they are not correctly // updated. Collection<UniprotProteinTranscript> variantsClone = new ArrayList<UniprotProteinTranscript>(); variantsClone.addAll(uniprotProtein.getSpliceVariants()); variantsClone.addAll(uniprotProtein.getFeatureChains()); for (UniprotProteinTranscript transcript : variantsClone) { proteins.addAll(createOrUpdateProteinTranscript(transcript, uniprotProtein, protein)); } if (!proteins.containsAll(spliceVariantsAndChains)) { if (proteins.size() < spliceVariantsAndChains.size()) { for (Object protNotUpdated : CollectionUtils.subtract(spliceVariantsAndChains, proteins)) { Protein prot = (Protein) protNotUpdated; if (prot.getActiveInstances().size() == 0) { deleteProtein(prot); uniprotServiceResult.addMessage( "The protein " + getProteinDescription(prot) + " is a protein transcript of " + getProteinDescription(protein) + " in IntAct but not in Uniprot." + " As it is not part of any interactions in IntAct we have deleted it."); } else if (ProteinUtils.isFromUniprot(prot)) { uniprotServiceResult.addError( UniprotServiceResult.SPLICE_VARIANT_IN_INTACT_BUT_NOT_IN_UNIPROT, "In Intact the protein " + getProteinDescription(prot) + " is a protein transcript of protein " + getProteinDescription(protein) + " but in Uniprot it is not the case. As it is part of interactions in IntAct we couldn't " + "delete it."); } } } else { Collection<Protein> spliceVariantsNotUpdated = new ArrayList<Protein>(spliceVariantsAndChains); spliceVariantsNotUpdated.removeAll(CollectionUtils.intersection(spliceVariantsAndChains, proteins)); for (Protein protNotUpdated : spliceVariantsNotUpdated) { if (protNotUpdated.getActiveInstances().size() == 0) { deleteProtein(protNotUpdated); uniprotServiceResult.addMessage("The protein " + getProteinDescription(protNotUpdated) + " is a protein transcript of " + getProteinDescription(protein) + " in IntAct but not in Uniprot." + " As it is not part of any interactions in IntAct we have deleted it."); } else if (ProteinUtils.isFromUniprot(protNotUpdated)) { uniprotServiceResult.addError( UniprotServiceResult.SPLICE_VARIANT_IN_INTACT_BUT_NOT_IN_UNIPROT, "In Intact the protein " + getProteinDescription(protNotUpdated) + " is a protein transcript of protein " + getProteinDescription(protein) + " but in Uniprot it is not the case. As it is part of interactions in IntAct we couldn't " + "delete it."); } } } } // Collection<ProteinTranscriptMatch> matches = findMatches( variants, variantsClone) ); /*Collection<ProteinTranscriptMatch> matches = findMatches( spliceVariantsAndChains, variantsClone ); for ( ProteinTranscriptMatch match : matches ) { if ( match.isSuccessful() ) { // update final UniprotProteinTranscript variant = match.getUniprotTranscript(); final Protein intactProtein = match.getIntactProtein(); if (ProteinUtils.isFromUniprot(intactProtein)){ updateProteinTranscript(intactProtein, protein, variant, uniprotProtein ); } if (variant.getSequence() != null || (variant.getSequence() == null && variant.isNullSequenceAllowed())) { proteins.add(intactProtein); } } else if ( match.hasNoIntact() ) { // TODO in the case of a global update, and the user requested splice variants without interactions to be deleted, // TODO we don't create splice variants when they are missing as they wouldn't have interactions anyways. // NOTE: this does not apply say in our curation environment as the users want to see imported SV so they can choose them // TODO test this final ProteinUpdateProcessorConfig config = ProteinUpdateContext.getInstance().getConfig(); final boolean globalProteinUpdate = config.isGlobalProteinUpdate(); final boolean deleteProteinTranscript = config.isDeleteProteinTranscriptWithoutInteractions(); if( ! globalProteinUpdate && !deleteProteinTranscript) { // create shallow Protein intactTranscript = createMinimalisticProteinTranscript( match.getUniprotTranscript(), protein.getAc(), protein.getBioSource(), uniprotProtein ); // update final UniprotProteinTranscript uniprotTranscript = match.getUniprotTranscript(); updateProteinTranscript( intactTranscript, protein, uniprotTranscript, uniprotProtein); proteinCreated(intactTranscript); if (uniprotTranscript.getSequence() != null || (uniprotTranscript.getSequence() == null && uniprotTranscript.isNullSequenceAllowed())) { proteins.add(intactTranscript); } } } else { Protein intactProteinTranscript = match.getIntactProtein(); if(intactProteinTranscript.getActiveInstances().size() == 0){ deleteProtein(intactProteinTranscript); uniprotServiceResult.addMessage("The protein " + getProteinDescription(intactProteinTranscript) + " is a protein transcript of " + getProteinDescription(protein) + " in IntAct but not in Uniprot." + " As it is not part of any interactions in IntAct we have deleted it." ); }else if (ProteinUtils.isFromUniprot(intactProteinTranscript)){ uniprotServiceResult.addError(UniprotServiceResult.SPLICE_VARIANT_IN_INTACT_BUT_NOT_IN_UNIPROT, "In Intact the protein "+ getProteinDescription(intactProteinTranscript) + " is a protein transcript of protein "+ getProteinDescription(protein)+ " but in Uniprot it is not the case. As it is part of interactions in IntAct we couldn't " + "delete it."); } } }*/ }