idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
6,200 | private BioPAXElement getIdentical ( BioPAXElement bpe ) { int key = bpe . hashCode ( ) ; List < BioPAXElement > list = equivalenceMap . get ( key ) ; if ( list != null ) { for ( BioPAXElement other : list ) { if ( other . equals ( bpe ) ) { return other ; } } } return null ; } | Searches the target model for an identical of given BioPAX element and returns this element if it finds it . |
6,201 | private void addIntoEquivalanceMap ( BioPAXElement bpe ) { int key = bpe . hashCode ( ) ; List < BioPAXElement > list = equivalenceMap . get ( key ) ; if ( list == null ) { list = new ArrayList < BioPAXElement > ( ) ; equivalenceMap . put ( key , list ) ; } list . add ( bpe ) ; } | Adds a BioPAX element into the equivalence map . |
6,202 | public static Set < BioPAXElement > runNeighborhood ( Set < BioPAXElement > sourceSet , Model model , int limit , Direction direction , Filter ... filters ) { Graph graph ; if ( model . getLevel ( ) == BioPAXLevel . L3 ) { if ( direction == Direction . UNDIRECTED ) { graph = new GraphL3Undirected ( model , filters ) ; direction = Direction . BOTHSTREAM ; } else { graph = new GraphL3 ( model , filters ) ; } } else return Collections . emptySet ( ) ; Set < Node > source = prepareSingleNodeSet ( sourceSet , graph ) ; if ( sourceSet . isEmpty ( ) ) return Collections . emptySet ( ) ; NeighborhoodQuery query = new NeighborhoodQuery ( source , direction , limit ) ; Set < GraphObject > resultWrappers = query . run ( ) ; return convertQueryResult ( resultWrappers , graph , true ) ; } | Gets neighborhood of the source set . |
6,203 | public static Set < BioPAXElement > runPathsBetween ( Set < BioPAXElement > sourceSet , Model model , int limit , Filter ... filters ) { Graph graph ; if ( model . getLevel ( ) == BioPAXLevel . L3 ) { graph = new GraphL3 ( model , filters ) ; } else return Collections . emptySet ( ) ; Collection < Set < Node > > sourceWrappers = prepareNodeSets ( sourceSet , graph ) ; if ( sourceWrappers . size ( ) < 2 ) return Collections . emptySet ( ) ; PathsBetweenQuery query = new PathsBetweenQuery ( sourceWrappers , limit ) ; Set < GraphObject > resultWrappers = query . run ( ) ; return convertQueryResult ( resultWrappers , graph , true ) ; } | Gets the graph constructed by the paths between the given seed nodes . Does not get paths between physical entities that belong the same entity reference . |
6,204 | public static Set < BioPAXElement > runGOI ( Set < BioPAXElement > sourceSet , Model model , int limit , Filter ... filters ) { return runPathsFromTo ( sourceSet , sourceSet , model , LimitType . NORMAL , limit , filters ) ; } | Gets paths between the seed nodes . |
6,205 | public static Set < BioPAXElement > runCommonStream ( Set < BioPAXElement > sourceSet , Model model , Direction direction , int limit , Filter ... filters ) { Graph graph ; if ( model . getLevel ( ) == BioPAXLevel . L3 ) { graph = new GraphL3 ( model , filters ) ; } else return Collections . emptySet ( ) ; Collection < Set < Node > > source = prepareNodeSets ( sourceSet , graph ) ; if ( sourceSet . size ( ) < 2 ) return Collections . emptySet ( ) ; CommonStreamQuery query = new CommonStreamQuery ( source , direction , limit ) ; Set < GraphObject > resultWrappers = query . run ( ) ; return convertQueryResult ( resultWrappers , graph , false ) ; } | Gets the elements in the common upstream or downstream of the seed |
6,206 | private static Set < BioPAXElement > convertQueryResult ( Set < GraphObject > resultWrappers , Graph graph , boolean removeDisconnected ) { Set < Object > result = graph . getWrappedSet ( resultWrappers ) ; Set < BioPAXElement > set = new HashSet < BioPAXElement > ( ) ; for ( Object o : result ) { set . add ( ( BioPAXElement ) o ) ; } if ( removeDisconnected ) { Set < BioPAXElement > remove = new HashSet < BioPAXElement > ( ) ; for ( BioPAXElement ele : set ) { if ( ele instanceof SimplePhysicalEntity && isDisconnected ( ( SimplePhysicalEntity ) ele , set ) ) { remove . add ( ele ) ; } } set . removeAll ( remove ) ; } return set ; } | Converts the query result from wrappers to wrapped BioPAX elements . |
6,207 | public static Set < Node > prepareSingleNodeSet ( Set < BioPAXElement > elements , Graph graph ) { Map < BioPAXElement , Set < PhysicalEntity > > map = getRelatedPhysicalEntityMap ( elements ) ; Set < PhysicalEntity > pes = new HashSet < PhysicalEntity > ( ) ; for ( Set < PhysicalEntity > valueSet : map . values ( ) ) { pes . addAll ( valueSet ) ; } Set < Node > nodes = graph . getWrapperSet ( pes ) ; Set < Node > inters = getSeedInteractions ( elements , graph ) ; nodes . addAll ( inters ) ; return nodes ; } | Gets the related wrappers of the given elements in a set . |
6,208 | public static Set < Node > prepareSingleNodeSetFromSets ( Set < Set < BioPAXElement > > sets , Graph graph ) { Set < BioPAXElement > elements = new HashSet < BioPAXElement > ( ) ; for ( Set < BioPAXElement > set : sets ) { elements . addAll ( set ) ; } return prepareSingleNodeSet ( elements , graph ) ; } | Gets the related wrappers of the given elements in the sets . |
6,209 | public static Map < BioPAXElement , Set < PhysicalEntity > > getRelatedPhysicalEntityMap ( Collection < BioPAXElement > elements ) { replaceXrefsWithRelatedER ( elements ) ; Map < BioPAXElement , Set < PhysicalEntity > > map = new HashMap < BioPAXElement , Set < PhysicalEntity > > ( ) ; for ( BioPAXElement ele : elements ) { Set < PhysicalEntity > ents = getRelatedPhysicalEntities ( ele , null ) ; if ( ! ents . isEmpty ( ) ) { map . put ( ele , ents ) ; } } return map ; } | Maps each BioPAXElement to its related PhysicalEntity objects . |
6,210 | protected static void replaceXrefsWithRelatedER ( Collection < BioPAXElement > elements ) { Set < EntityReference > ers = new HashSet < EntityReference > ( ) ; Set < Xref > xrefs = new HashSet < Xref > ( ) ; for ( BioPAXElement element : elements ) { if ( element instanceof Xref ) { xrefs . add ( ( Xref ) element ) ; for ( XReferrable able : ( ( Xref ) element ) . getXrefOf ( ) ) { if ( able instanceof EntityReference ) { ers . add ( ( EntityReference ) able ) ; } } } } elements . removeAll ( xrefs ) ; for ( EntityReference er : ers ) { if ( ! elements . contains ( er ) ) elements . add ( er ) ; } } | Replaces Xref objects with the related EntityReference objects . This is required for the use case when user provides multiple xrefs that point to the same ER . |
6,211 | public static Set < PhysicalEntity > getRelatedPhysicalEntities ( BioPAXElement element , Set < PhysicalEntity > pes ) { if ( pes == null ) pes = new HashSet < PhysicalEntity > ( ) ; if ( element instanceof PhysicalEntity ) { PhysicalEntity pe = ( PhysicalEntity ) element ; if ( ! pes . contains ( pe ) ) { pes . add ( pe ) ; for ( Complex cmp : pe . getComponentOf ( ) ) { getRelatedPhysicalEntities ( cmp , pes ) ; } addEquivalentsComplexes ( pe , pes ) ; } } else if ( element instanceof Xref ) { for ( XReferrable xrable : ( ( Xref ) element ) . getXrefOf ( ) ) { getRelatedPhysicalEntities ( xrable , pes ) ; } } else if ( element instanceof EntityReference ) { EntityReference er = ( EntityReference ) element ; for ( SimplePhysicalEntity spe : er . getEntityReferenceOf ( ) ) { getRelatedPhysicalEntities ( spe , pes ) ; } for ( EntityReference parentER : er . getMemberEntityReferenceOf ( ) ) { getRelatedPhysicalEntities ( parentER , pes ) ; } } return pes ; } | Gets the related PhysicalEntity objects of the given BioPAXElement in level 3 models . |
6,212 | private static void addEquivalentsComplexes ( PhysicalEntity pe , Set < PhysicalEntity > pes ) { addEquivalentsComplexes ( pe , true , pes ) ; } | Adds equivalents and parent complexes of the given PhysicalEntity to the parameter set . |
6,213 | public static Set < Node > getSeedInteractions ( Collection < BioPAXElement > elements , Graph graph ) { Set < Node > nodes = new HashSet < Node > ( ) ; for ( BioPAXElement ele : elements ) { if ( ele instanceof Conversion || ele instanceof TemplateReaction || ele instanceof Control ) { GraphObject go = graph . getGraphObject ( ele ) ; if ( go instanceof Node ) { nodes . add ( ( Node ) go ) ; } } } return nodes ; } | Extracts the querible interactions from the elements . |
6,214 | public String getColumnValue ( SIFInteraction inter ) { switch ( type ) { case MEDIATOR : return concat ( inter . getMediatorIDs ( ) ) ; case PATHWAY : return concat ( inter . getPathwayNames ( ) ) ; case PATHWAY_URI : return concat ( inter . getPathwayUris ( ) ) ; case PUBMED : return concat ( inter . getPublicationIDs ( true ) ) ; case PMC : return concat ( inter . getPublicationIDs ( false ) ) ; case RESOURCE : return concat ( inter . getDataSources ( ) ) ; case SOURCE_LOC : return concat ( inter . getCellularLocationsOfSource ( ) ) ; case TARGET_LOC : return concat ( inter . getCellularLocationsOfTarget ( ) ) ; case COMMENTS : return concat ( inter . getMediatorComments ( ) ) ; case CUSTOM : { Set < String > set = new HashSet < String > ( ) ; for ( PathAccessor acc : accessors ) { for ( Object o : acc . getValueFromBeans ( inter . mediators ) ) { set . add ( o . toString ( ) ) ; } } List < String > list = new ArrayList < String > ( set ) ; Collections . sort ( list ) ; return concat ( list ) ; } default : throw new RuntimeException ( "Unhandled type: " + type + ". This shouldn't be happening." ) ; } } | Get the string to write in the output file . |
6,215 | public void writeSBGN ( Model model , String file ) { Sbgn sbgn = createSBGN ( model ) ; try { SbgnUtil . writeToFile ( sbgn , new File ( file ) ) ; } catch ( JAXBException e ) { throw new RuntimeException ( "writeSBGN, SbgnUtil.writeToFile failed" , e ) ; } } | Converts the given model to SBGN and writes in the specified file . |
6,216 | public void writeSBGN ( Model model , OutputStream stream ) { Sbgn sbgn = createSBGN ( model ) ; try { JAXBContext context = JAXBContext . newInstance ( "org.sbgn.bindings" ) ; Marshaller marshaller = context . createMarshaller ( ) ; marshaller . setProperty ( Marshaller . JAXB_FORMATTED_OUTPUT , Boolean . TRUE ) ; marshaller . marshal ( sbgn , stream ) ; } catch ( JAXBException e ) { throw new RuntimeException ( "writeSBGN: JAXB marshalling failed" , e ) ; } } | Converts the given model to SBGN and writes in the specified output stream . |
6,217 | private void processControllers ( Set < Control > controls , Glyph process ) { for ( Control ctrl : controls ) { Glyph g = createControlStructure ( ctrl ) ; if ( g != null ) { createArc ( g , process , getControlType ( ctrl ) , null ) ; processControllers ( ctrl . getControlledOf ( ) , g ) ; } } } | Associate all the controllers of this process ; |
6,218 | private String extractGeneSymbol ( Xref xref ) { if ( xref . getDb ( ) != null && ( xref . getDb ( ) . equalsIgnoreCase ( "HGNC Symbol" ) || xref . getDb ( ) . equalsIgnoreCase ( "Gene Symbol" ) || xref . getDb ( ) . equalsIgnoreCase ( "HGNC" ) ) ) { String ref = xref . getId ( ) ; if ( ref != null ) { ref = ref . trim ( ) ; if ( ref . contains ( ":" ) ) ref = ref . substring ( ref . indexOf ( ":" ) + 1 ) ; if ( ref . contains ( "_" ) ) ref = ref . substring ( ref . indexOf ( "_" ) + 1 ) ; if ( ! HGNC . containsSymbol ( ref ) && Character . isDigit ( ref . charAt ( 0 ) ) ) { ref = HGNC . getSymbol ( ref ) ; } } return ref ; } return null ; } | Searches for gene symbol in Xref . |
6,219 | public void setRangeRestriction ( Map < Class < ? extends BioPAXElement > , Set < Class < ? extends BioPAXElement > > > restrictedRanges ) { this . restrictedRanges = restrictedRanges ; } | This method sets all range restrictions . |
6,220 | public Collection < BioPAXElement > generate ( Match match , int ... ind ) { Collection < BioPAXElement > gen = new HashSet < BioPAXElement > ( con [ 0 ] . generate ( match , ind ) ) ; Set < BioPAXElement > input = new HashSet < BioPAXElement > ( ) ; Set < BioPAXElement > output = new HashSet < BioPAXElement > ( gen ) ; int [ ] tempInd = { 0 , 1 } ; for ( int i = 1 ; i < con . length ; i ++ ) { if ( output . isEmpty ( ) ) break ; input . clear ( ) ; input . addAll ( output ) ; output . clear ( ) ; for ( BioPAXElement ele : input ) { Match m = new Match ( 2 ) ; m . set ( ele , 0 ) ; output . addAll ( con [ i ] . generate ( m , tempInd ) ) ; } } return output ; } | Chains the member constraints and returns the output of the last constraint . |
6,221 | public Collection < BioPAXElement > generate ( Match match , int ... ind ) { Control ctrl = ( Control ) match . get ( ind [ 0 ] ) ; return new HashSet < BioPAXElement > ( getRelatedERs ( ctrl ) ) ; } | Navigates to the related ERs of the controllers of the given Control . |
6,222 | public Collection < BioPAXElement > generate ( Match match , int ... ind ) { PhysicalEntity pe = ( PhysicalEntity ) match . get ( ind [ 0 ] ) ; Conversion conv = ( Conversion ) match . get ( ind [ 1 ] ) ; if ( ! ( ( peType == RelType . INPUT && getConvParticipants ( conv , RelType . INPUT ) . contains ( pe ) ) || ( peType == RelType . OUTPUT && getConvParticipants ( conv , RelType . OUTPUT ) . contains ( pe ) ) ) ) throw new IllegalArgumentException ( "peType = " + peType + ", and related participant set does not contain this PE. Conv dir = " + getDirection ( conv ) + " conv.id=" + conv . getUri ( ) + " pe.id=" + pe . getUri ( ) ) ; boolean rightContains = conv . getRight ( ) . contains ( pe ) ; boolean leftContains = conv . getLeft ( ) . contains ( pe ) ; assert rightContains || leftContains : "PE is not a participant." ; Set < BioPAXElement > result = new HashSet < BioPAXElement > ( ) ; ConversionDirectionType avoidDir = ( leftContains && rightContains ) ? null : peType == RelType . OUTPUT ? ( leftContains ? ConversionDirectionType . LEFT_TO_RIGHT : ConversionDirectionType . RIGHT_TO_LEFT ) : ( rightContains ? ConversionDirectionType . LEFT_TO_RIGHT : ConversionDirectionType . RIGHT_TO_LEFT ) ; for ( Object o : controlledOf . getValueFromBean ( conv ) ) { Control ctrl = ( Control ) o ; ConversionDirectionType dir = getDirection ( conv , ctrl ) ; if ( avoidDir != null && dir == avoidDir ) continue ; if ( blacklist != null && blacklist . isUbique ( pe , conv , dir , peType ) ) continue ; result . add ( ctrl ) ; } return result ; } | According to the relation between PhysicalEntity and the Conversion checks of the Control is relevant . If relevant it is retrieved . |
6,223 | public void init ( ) { ControlType type = ctrl . getControlType ( ) ; if ( type != null && type . toString ( ) . startsWith ( "I" ) ) { sign = NEGATIVE ; } else { sign = POSITIVE ; } if ( ctrl instanceof TemplateReactionRegulation ) transcription = true ; } | Extracts the sign and the type of the Control . |
6,224 | private void bindUpstream ( BioPAXElement element ) { AbstractNode node = ( AbstractNode ) graph . getGraphObject ( element ) ; if ( node != null ) { Edge edge = new EdgeL3 ( node , this , graph ) ; node . getDownstreamNoInit ( ) . add ( edge ) ; this . getUpstreamNoInit ( ) . add ( edge ) ; } } | Puts the wrapper of the parameter element to the upstream of this Control . |
6,225 | public Set getValueFromModel ( Model model ) { Set < ? extends BioPAXElement > domains = new HashSet < BioPAXElement > ( model . getObjects ( this . getDomain ( ) ) ) ; return getValueFromBeans ( domains ) ; } | This method runs the path query on all the elements within the model . |
6,226 | private void load ( String filename ) { try { load ( new FileInputStream ( filename ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } | Reads data from the given file . |
6,227 | private void load ( InputStream is ) { try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( is ) ) ; for ( String line = reader . readLine ( ) ; line != null ; line = reader . readLine ( ) ) { String [ ] tok = line . split ( DELIM ) ; if ( tok . length >= 3 ) { addEntry ( tok [ 0 ] , Integer . parseInt ( tok [ 1 ] ) , convertContext ( tok [ 2 ] ) ) ; } } reader . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; context = null ; score = null ; } } | Reads data from the input stream and loads itself . |
6,228 | public void addEntry ( String id , int score , RelType context ) { this . score . put ( id , score ) ; this . context . put ( id , context ) ; } | Adds a new blacklisted ID . |
6,229 | public void write ( String filename ) { try { write ( new FileOutputStream ( filename ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } | Dumps data to the given file . |
6,230 | public void write ( OutputStream os ) { List < String > ids = new ArrayList < String > ( score . keySet ( ) ) ; final Map < String , Integer > score = this . score ; Collections . sort ( ids , new Comparator < String > ( ) { public int compare ( String o1 , String o2 ) { return score . get ( o2 ) . compareTo ( score . get ( o1 ) ) ; } } ) ; try { BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( os ) ) ; boolean notFirst = false ; for ( String id : ids ) { if ( notFirst ) writer . write ( "\n" ) ; else notFirst = true ; writer . write ( id + DELIM + score . get ( id ) + DELIM + convertContext ( context . get ( id ) ) ) ; } writer . close ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Dumps data to the given output stream . |
6,231 | private RelType convertContext ( String type ) { if ( type . equals ( "I" ) ) return RelType . INPUT ; if ( type . equals ( "O" ) ) return RelType . OUTPUT ; if ( type . equals ( "B" ) ) return null ; throw new IllegalArgumentException ( "Unknown context: " + type ) ; } | Converts text context to enum . |
6,232 | private Set < String > getLeastUbique ( Collection < String > ids ) { Set < String > select = new HashSet < String > ( ) ; int s = getLeastScore ( ids ) ; for ( String id : ids ) { if ( score . get ( id ) == s ) select . add ( id ) ; } return select ; } | Gets the subset with the least score . |
6,233 | private int getLeastScore ( Collection < String > ids ) { int s = Integer . MAX_VALUE ; for ( String id : ids ) { if ( score . get ( id ) < s ) s = score . get ( id ) ; } return s ; } | Gets the least score of the given ids . |
6,234 | private boolean isUbiqueInBothContexts ( String id ) { return context . containsKey ( id ) && context . get ( id ) == null ; } | Checks if the given ID is blacklisted in both contexts together . |
6,235 | private boolean isUbique ( String id , RelType context ) { if ( context == null ) return this . context . containsKey ( id ) ; if ( ! isUbique ( id ) ) return false ; RelType ctx = this . context . get ( id ) ; return ctx == null || ctx . equals ( context ) ; } | Checks if the given ID is blacklisted in the given context . |
6,236 | public boolean isUbique ( PhysicalEntity pe ) { String id = getSMRID ( pe ) ; return id != null && isUbique ( id ) ; } | Checks if the given entity is blacklisted in at least one context . |
6,237 | public boolean isUbiqueInBothContexts ( PhysicalEntity pe ) { String id = getSMRID ( pe ) ; return id != null && isUbiqueInBothContexts ( id ) ; } | Checks if the given entity is blacklisted in both context together . |
6,238 | public boolean isUbique ( PhysicalEntity pe , Conversion conv , ConversionDirectionType dir , RelType context ) { String id = getSMRID ( pe ) ; if ( id == null ) return false ; if ( dir == null ) throw new IllegalArgumentException ( "The conversion direction has to be specified." ) ; if ( context == null ) throw new IllegalArgumentException ( "The context has to be only one type." ) ; Set < PhysicalEntity > parts ; if ( dir == ConversionDirectionType . REVERSIBLE ) { if ( conv . getLeft ( ) . contains ( pe ) ) parts = conv . getLeft ( ) ; else if ( conv . getRight ( ) . contains ( pe ) ) parts = conv . getRight ( ) ; else throw new IllegalArgumentException ( "The PhysicalEntity has to be at least one " + "side of the Conversion" ) ; } else { parts = dir == ConversionDirectionType . LEFT_TO_RIGHT ? context == RelType . INPUT ? conv . getLeft ( ) : conv . getRight ( ) : context == RelType . OUTPUT ? conv . getLeft ( ) : conv . getRight ( ) ; } if ( dir == ConversionDirectionType . REVERSIBLE ) return getUbiques ( parts , null ) . contains ( pe ) ; else return getUbiques ( parts , context ) . contains ( pe ) ; } | Checks if the given entity is blacklisted for the given Conversion assuming the Conversion flows towards the given direction and the entity is in given context . |
6,239 | private String getSMRID ( PhysicalEntity pe ) { if ( pe instanceof SmallMolecule ) { EntityReference er = ( ( SmallMolecule ) pe ) . getEntityReference ( ) ; if ( er != null ) return er . getUri ( ) ; } return null ; } | Gets the ID of the reference of the given entity if it is a small molecule . |
6,240 | protected void addToDownstream ( BioPAXElement pe , Graph graph ) { AbstractNode node = ( AbstractNode ) graph . getGraphObject ( pe ) ; if ( node != null ) { EdgeL3 edge = new EdgeL3 ( this , node , graph ) ; edge . setTranscription ( true ) ; node . getUpstreamNoInit ( ) . add ( edge ) ; this . getDownstreamNoInit ( ) . add ( edge ) ; } } | Binds the given PhysicalEntity to the downstream . |
6,241 | public void initDownstream ( ) { for ( Interaction inter : getDownstreamInteractions ( pe . getParticipantOf ( ) ) ) { AbstractNode node = ( AbstractNode ) graph . getGraphObject ( inter ) ; if ( node == null ) continue ; if ( inter instanceof Conversion ) { Conversion conv = ( Conversion ) inter ; ConversionWrapper conW = ( ConversionWrapper ) node ; if ( conv . getConversionDirection ( ) == ConversionDirectionType . REVERSIBLE && conv . getRight ( ) . contains ( pe ) ) { node = conW . getReverse ( ) ; } } Edge edge = new EdgeL3 ( this , node , graph ) ; this . getDownstreamNoInit ( ) . add ( edge ) ; node . getUpstreamNoInit ( ) . add ( edge ) ; } } | Binds to downstream interactions . |
6,242 | protected Set < Interaction > getDownstreamInteractions ( Collection < Interaction > inters ) { Set < Interaction > set = new HashSet < Interaction > ( ) ; for ( Interaction inter : inters ) { if ( inter instanceof Conversion ) { Conversion conv = ( Conversion ) inter ; ConversionDirectionType dir = conv . getConversionDirection ( ) ; if ( dir == ConversionDirectionType . REVERSIBLE || ( dir == ConversionDirectionType . RIGHT_TO_LEFT && conv . getRight ( ) . contains ( pe ) ) || ( ( dir == ConversionDirectionType . LEFT_TO_RIGHT || dir == null ) && conv . getLeft ( ) . contains ( pe ) ) ) { set . add ( conv ) ; } } else if ( inter instanceof Control ) { set . add ( inter ) ; } } return set ; } | Gets the downstream interactions among the given set . |
6,243 | private Set < Conversion > getRelatedConversions ( Collection < Interaction > inters ) { Set < Conversion > set = new HashSet < Conversion > ( ) ; for ( Interaction inter : inters ) { if ( inter instanceof Conversion ) { set . add ( ( Conversion ) inter ) ; } else if ( inter instanceof Control ) { getRelatedConversions ( ( Control ) inter , set ) ; } } return set ; } | Get all related Conversions of the given Interaction set . |
6,244 | private Set < Conversion > getRelatedConversions ( Control ctrl , Set < Conversion > set ) { for ( Process process : ctrl . getControlled ( ) ) { if ( process instanceof Conversion ) { set . add ( ( Conversion ) process ) ; } else if ( process instanceof Control ) { getRelatedConversions ( ( Control ) process , set ) ; } } return set ; } | Recursively searches the related Conversions of a Control . |
6,245 | public void convert ( InputStream inputStream , OutputStream outputStream , boolean forceInteractionToComplex ) throws IOException , PsimiXmlReaderException { if ( inputStream == null || outputStream == null ) { throw new IllegalArgumentException ( "convert(): " + "one or more null arguments." ) ; } PsimiXmlReader reader = new PsimiXmlReader ( ) ; EntrySet entrySet = reader . read ( inputStream ) ; inputStream . close ( ) ; convert ( entrySet , outputStream , forceInteractionToComplex ) ; } | Converts the PSI - MI inputStream into BioPAX outputStream . Streams will be closed by the converter . |
6,246 | public void convertTab ( InputStream inputStream , OutputStream outputStream , boolean forceInteractionToComplex ) throws IOException , PsimiTabException { if ( inputStream == null || outputStream == null ) { throw new IllegalArgumentException ( "convertTab(): " + "one or more null arguments." ) ; } PsimiTabReader reader = new PsimiTabReader ( ) ; Collection < BinaryInteraction > interactions = reader . read ( inputStream ) ; Tab2Xml tab2Xml = new Tab2Xml ( ) ; EntrySet entrySet ; try { entrySet = tab2Xml . convert ( interactions ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( XmlConversionException e ) { throw new RuntimeException ( e ) ; } inputStream . close ( ) ; convert ( entrySet , outputStream , forceInteractionToComplex ) ; } | Converts the PSI - MITAB inputStream into BioPAX outputStream . Streams will be closed by the converter . |
6,247 | public void convert ( EntrySet entrySet , OutputStream outputStream , boolean forceInteractionToComplex ) { if ( entrySet == null || outputStream == null ) { throw new IllegalArgumentException ( "convert: one or more null arguments." ) ; } if ( entrySet . getLevel ( ) != 2 ) { throw new IllegalArgumentException ( "convert: only PSI-MI Level 2.5 is supported." ) ; } final Model model = BioPAXLevel . L3 . getDefaultFactory ( ) . createModel ( ) ; model . setXmlBase ( xmlBase ) ; EntryMapper entryMapper = new EntryMapper ( model , forceInteractionToComplex ) ; for ( Entry entry : entrySet . getEntries ( ) ) { entryMapper . run ( entry ) ; } entrySet . getEntries ( ) . clear ( ) ; entrySet = null ; ( new SimpleIOHandler ( ) ) . convertToOWL ( model , outputStream ) ; } | Converts the PSI interactions from the EntrySet and places into BioPAX output stream . Stream will be closed by the converter . |
6,248 | public void writeResult ( Map < BioPAXElement , List < Match > > matches , OutputStream out ) throws IOException { OutputStreamWriter writer = new OutputStreamWriter ( out ) ; for ( BioPAXElement ele : matches . keySet ( ) ) { Set < String > syms = new HashSet < String > ( ) ; for ( Match m : matches . get ( ele ) ) { ProteinReference pr = ( ProteinReference ) m . get ( "PR" , getPattern ( ) ) ; String sym = getGeneSymbol ( pr ) ; if ( sym != null ) syms . add ( sym ) ; } if ( syms . size ( ) > 1 ) { writer . write ( "\n" + ele . getUri ( ) ) ; for ( Object o : controlAcc . getValueFromBean ( ele ) ) { Control ctrl = ( Control ) o ; writer . write ( " " + ctrl . getUri ( ) ) ; } for ( String sym : syms ) { writer . write ( "\t" + sym ) ; } } } writer . flush ( ) ; } | Writes the IDs of interaction then gene symbols of related proteins in a line . |
6,249 | public Collection < BioPAXElement > generate ( Match match , int ... ind ) { Collection < BioPAXElement > gen = con . generate ( match , ind ) ; gen . add ( match . get ( ind [ selfIndex ] ) ) ; return gen ; } | Gets the first mapped element along with the generated elements of wrapped constraint . |
6,250 | public boolean satisfies ( Match match , int ... ind ) { return match . get ( ind [ selfIndex ] ) == match . get ( ind [ ind . length - 1 ] ) || super . satisfies ( match , ind ) ; } | Checks if the last index is either generated or equal to the first element . |
6,251 | public GraphObject getGraphObject ( Object obj ) { String key = getKey ( obj ) ; GraphObject go = objectMap . get ( key ) ; if ( go == null ) { Node node = wrap ( obj ) ; if ( node != null ) { objectMap . put ( key , node ) ; node . init ( ) ; } } return objectMap . get ( key ) ; } | Gets the related wrapper for the given object creates the wrapper if not created before . |
6,252 | public String convert ( SIFInteraction inter ) { String s = inter . toString ( ) ; for ( OutputColumn column : columns ) { s += "\t" + column . getColumnValue ( inter ) ; } return s ; } | Prepares the line in the output file for the given interaction . |
6,253 | private static Map < String , Set < BioPAXElement > > collectEntityRefs ( Collection < SIFInteraction > inters ) { Map < String , Set < BioPAXElement > > map = new HashMap < String , Set < BioPAXElement > > ( ) ; for ( SIFInteraction inter : inters ) { if ( ! map . containsKey ( inter . sourceID ) ) map . put ( inter . sourceID , new HashSet < BioPAXElement > ( ) ) ; if ( ! map . containsKey ( inter . targetID ) ) map . put ( inter . targetID , new HashSet < BioPAXElement > ( ) ) ; map . get ( inter . sourceID ) . addAll ( inter . sourceERs ) ; map . get ( inter . targetID ) . addAll ( inter . targetERs ) ; } return map ; } | Collects the sources and targets in given interactions . |
6,254 | private static String concat ( Collection < String > col ) { StringBuilder b = new StringBuilder ( ) ; boolean first = true ; for ( String s : col ) { if ( first ) first = false ; else b . append ( ";" ) ; b . append ( s ) ; } return b . toString ( ) ; } | Concatenates the given collection of strings into a single string where values are separated with a semicolon . |
6,255 | public void initUpstream ( ) { NucleicAcid nuc = tempReac . getTemplate ( ) ; if ( nuc != null ) addToUpstream ( nuc , getGraph ( ) ) ; for ( Control cont : tempReac . getControlledOf ( ) ) { addToUpstream ( cont , graph ) ; } } | Binds to template and controllers . |
6,256 | protected void addToUpstream ( BioPAXElement ele , org . biopax . paxtools . query . model . Graph graph ) { AbstractNode node = ( AbstractNode ) graph . getGraphObject ( ele ) ; if ( node == null ) return ; Edge edge = new EdgeL3 ( node , this , graph ) ; if ( isTranscription ( ) ) { if ( node instanceof ControlWrapper ) { ( ( ControlWrapper ) node ) . setTranscription ( true ) ; } } node . getDownstreamNoInit ( ) . add ( edge ) ; this . getUpstreamNoInit ( ) . add ( edge ) ; } | Binds the given element to the upstream . |
6,257 | public Set < GraphObject > run ( ) { Map < GraphObject , Integer > candidate = new HashMap < GraphObject , Integer > ( ) ; Set < GraphObject > result = new HashSet < GraphObject > ( ) ; for ( Set < Node > source : sourceSet ) { BFS bfs = new BFS ( source , null , direction , limit ) ; Map < GraphObject , Integer > BFSResult = new HashMap < GraphObject , Integer > ( ) ; BFSResult . putAll ( bfs . run ( ) ) ; for ( GraphObject go : BFSResult . keySet ( ) ) { setLabel ( go , ( getLabel ( go ) + 1 ) ) ; } candidate . putAll ( BFSResult ) ; } for ( GraphObject go : candidate . keySet ( ) ) { if ( getLabel ( go ) == sourceSet . size ( ) ) { result . add ( go ) ; } } return result ; } | Method to run the query . |
6,258 | public BioPAXElement get ( String label , Pattern p ) { return variables [ p . indexOf ( label ) ] ; } | Gets element corresponding to the given label in the pattern . |
6,259 | public List < BioPAXElement > get ( String [ ] label , Pattern p ) { if ( label == null ) return Collections . emptyList ( ) ; List < BioPAXElement > list = new ArrayList < BioPAXElement > ( label . length ) ; for ( String lab : label ) { list . add ( variables [ p . indexOf ( lab ) ] ) ; } return list ; } | Gets elements corresponding to the given labels in the pattern . |
6,260 | public String getAName ( BioPAXElement ele ) { String name = null ; if ( ele instanceof Named ) { Named n = ( Named ) ele ; if ( n . getDisplayName ( ) != null && n . getDisplayName ( ) . length ( ) > 0 ) name = n . getDisplayName ( ) ; else if ( n . getStandardName ( ) != null && n . getStandardName ( ) . length ( ) > 0 ) name = n . getStandardName ( ) ; else if ( ! n . getName ( ) . isEmpty ( ) && n . getName ( ) . iterator ( ) . next ( ) . length ( ) > 0 ) name = n . getName ( ) . iterator ( ) . next ( ) ; } if ( name == null ) name = ele . getUri ( ) ; return name + " (" + ele . getModelInterface ( ) . getName ( ) . substring ( ele . getModelInterface ( ) . getName ( ) . lastIndexOf ( "." ) + 1 ) + ")" ; } | Finds a name for the variable . |
6,261 | public void init ( ) { if ( conv . getConversionDirection ( ) == ConversionDirectionType . REVERSIBLE && this . reverse == null ) { reverse = new ConversionWrapper ( conv , ( GraphL3 ) graph ) ; this . direction = LEFT_TO_RIGHT ; reverse . direction = RIGHT_TO_LEFT ; reverse . reverse = this ; } else if ( conv . getConversionDirection ( ) == ConversionDirectionType . RIGHT_TO_LEFT ) { this . direction = RIGHT_TO_LEFT ; } else { this . direction = LEFT_TO_RIGHT ; } } | Extracts the direction creates the reverse if necessary . |
6,262 | public void initUpstream ( ) { if ( direction == LEFT_TO_RIGHT ) { for ( PhysicalEntity pe : conv . getLeft ( ) ) { addToUpstream ( pe , getGraph ( ) ) ; } } else { for ( PhysicalEntity pe : conv . getRight ( ) ) { addToUpstream ( pe , getGraph ( ) ) ; } } for ( Control cont : conv . getControlledOf ( ) ) { if ( cont instanceof Catalysis ) { Catalysis cat = ( Catalysis ) cont ; if ( ( cat . getCatalysisDirection ( ) == CatalysisDirectionType . LEFT_TO_RIGHT && direction == RIGHT_TO_LEFT ) || ( cat . getCatalysisDirection ( ) == CatalysisDirectionType . RIGHT_TO_LEFT && direction == LEFT_TO_RIGHT ) ) { continue ; } } addToUpstream ( cont , graph ) ; } } | Binds inputs and controllers . |
6,263 | public void initDownstream ( ) { if ( direction == RIGHT_TO_LEFT ) { for ( PhysicalEntity pe : conv . getLeft ( ) ) { addToDownstream ( pe , getGraph ( ) ) ; } } else { for ( PhysicalEntity pe : conv . getRight ( ) ) { addToDownstream ( pe , getGraph ( ) ) ; } } } | Binds products . |
6,264 | public Pattern getPattern ( ) { if ( pattern == null ) { pattern = constructPattern ( ) ; if ( this instanceof SIFMiner && idFetcher != null && idMap != null ) { pattern . add ( new HasAnID ( idFetcher , idMap ) , ( ( SIFMiner ) this ) . getSourceLabel ( ) ) ; pattern . add ( new HasAnID ( idFetcher , idMap ) , ( ( SIFMiner ) this ) . getTargetLabel ( ) ) ; } pattern . optimizeConstraintOrder ( ) ; } return pattern ; } | Gets the pattern constructs if null . |
6,265 | public boolean isInhibition ( Control ctrl ) { return ctrl . getControlType ( ) != null && ctrl . getControlType ( ) . toString ( ) . startsWith ( "I" ) ; } | Checks if the type of a Control is inhibition . |
6,266 | public Set < String > toStringSet ( Set < ModificationFeature > set ) { List < ModificationFeature > list = new ArrayList < ModificationFeature > ( set ) ; Collections . sort ( list , new Comparator < ModificationFeature > ( ) { public int compare ( ModificationFeature o1 , ModificationFeature o2 ) { String t1 = getModificationTerm ( o1 ) ; String t2 = getModificationTerm ( o2 ) ; Integer l1 = getPositionStart ( o1 ) ; Integer l2 = getPositionStart ( o2 ) ; if ( t1 == null && t2 == null ) return l1 . compareTo ( l2 ) ; if ( t1 == null ) return 1 ; if ( t2 == null ) return - 1 ; if ( t1 . equals ( t2 ) ) return l1 . compareTo ( l2 ) ; return t1 . compareTo ( t2 ) ; } } ) ; return getInString ( list ) ; } | Sorts the modifications and gets them in a String . |
6,267 | private Set < String > getInString ( List < ModificationFeature > list ) { Set < String > text = new HashSet < String > ( list . size ( ) ) ; for ( ModificationFeature mf : list ) { String term = getModificationTerm ( mf ) ; String loc = getPositionInString ( mf ) ; if ( term != null ) { String s = term + loc ; if ( ! text . contains ( s ) ) text . add ( s ) ; } } return text ; } | Gets the modifications is a string that is separated with comma . |
6,268 | public String getModificationTerm ( ModificationFeature mf ) { Set vals = TERM_ACC . getValueFromBean ( mf ) ; if ( vals . isEmpty ( ) ) return null ; return vals . iterator ( ) . next ( ) . toString ( ) ; } | Gets the String term of the modification feature . |
6,269 | public int getPositionStart ( ModificationFeature mf ) { Set vals = SITE_ACC . getValueFromBean ( mf ) ; if ( ! vals . isEmpty ( ) ) { return ( ( Integer ) vals . iterator ( ) . next ( ) ) ; } vals = INTERVAL_BEGIN_ACC . getValueFromBean ( mf ) ; if ( ! vals . isEmpty ( ) ) { return ( ( Integer ) vals . iterator ( ) . next ( ) ) ; } return - 1 ; } | Gets the first position of the modification feature . |
6,270 | public String getPositionInString ( ModificationFeature mf ) { Set vals = SITE_ACC . getValueFromBean ( mf ) ; if ( ! vals . isEmpty ( ) ) { int x = ( ( Integer ) vals . iterator ( ) . next ( ) ) ; if ( x > 0 ) return "@" + x ; } vals = INTERVAL_BEGIN_ACC . getValueFromBean ( mf ) ; if ( ! vals . isEmpty ( ) ) { int begin = ( ( Integer ) vals . iterator ( ) . next ( ) ) ; vals = INTERVAL_END_ACC . getValueFromBean ( mf ) ; if ( ! vals . isEmpty ( ) ) { int end = ( ( Integer ) vals . iterator ( ) . next ( ) ) ; if ( begin > 0 && end > 0 && begin <= end ) { if ( begin == end ) return "@" + begin ; else return "@" + "[" + begin + "-" + end + "]" ; } } } return "" ; } | Gets the position of the modification feature as a String . |
6,271 | protected Set < String > getModifications ( Match m , String label ) { PhysicalEntity pe = ( PhysicalEntity ) m . get ( label , getPattern ( ) ) ; return toStringSet ( new HashSet < ModificationFeature > ( FEAT_ACC . getValueFromBean ( pe ) ) ) ; } | Gets modifications of the given element in a string . The element has to be a PhysicalEntity . |
6,272 | protected String concat ( Set < String > set , String sep ) { String s = "" ; int i = set . size ( ) ; for ( String ss : set ) { s += ss ; if ( -- i > 0 ) s += sep ; } return s ; } | Converts the set of string to a single string . |
6,273 | protected int sign ( Control ctrl ) { ControlType type = ctrl . getControlType ( ) ; if ( type != null && type . name ( ) . startsWith ( "I" ) ) return - 1 ; return 1 ; } | Identifies negative and positive controls . Assumes positive by default . |
6,274 | protected int sign ( Match m , String ... ctrlLabel ) { int sign = 1 ; for ( String lab : ctrlLabel ) { Control ctrl = ( Control ) m . get ( lab , getPattern ( ) ) ; sign *= sign ( ctrl ) ; } return sign ; } | Checks the cumulative sign of the chained controls . |
6,275 | protected boolean labeledInactive ( Match m , String simpleLabel , String complexLabel ) { PhysicalEntityChain chain = getChain ( m , simpleLabel , complexLabel ) ; PhysicalEntityChain . Activity activity = chain . checkActivityLabel ( ) ; return activity == PhysicalEntityChain . Activity . INACTIVE ; } | Checks if a PE chain is labeled as inactive . |
6,276 | protected void writeResultDetailed ( Map < BioPAXElement , List < Match > > matches , OutputStream out , int columns ) throws IOException { OutputStreamWriter writer = new OutputStreamWriter ( out ) ; String header = getHeader ( ) ; if ( header != null ) { writer . write ( header ) ; } else { for ( int i = 0 ; i < columns ; i ++ ) { writer . write ( "col-" + ( i + 1 ) ) ; if ( i < columns - 1 ) writer . write ( "\t" ) ; } } Set < String > mem = new HashSet < String > ( ) ; for ( BioPAXElement ele : matches . keySet ( ) ) { for ( Match m : matches . get ( ele ) ) { String line = "" ; boolean aborted = false ; for ( int i = 0 ; i < columns ; i ++ ) { String s = getValue ( m , i ) ; if ( s == null ) { aborted = true ; break ; } else { line += s + "\t" ; } } if ( aborted ) continue ; line = line . trim ( ) ; if ( ! mem . contains ( line ) ) { writer . write ( "\n" + line ) ; mem . add ( line ) ; } } } writer . flush ( ) ; } | Writes the result as a tab delimited format where the column values are customized . |
6,277 | public Set < SIFInteraction > createSIFInteraction ( Match m , IDFetcher fetcher ) { BioPAXElement sourceBpe = m . get ( ( ( SIFMiner ) this ) . getSourceLabel ( ) , getPattern ( ) ) ; BioPAXElement targetBpe = m . get ( ( ( SIFMiner ) this ) . getTargetLabel ( ) , getPattern ( ) ) ; Set < String > sources = fetchIDs ( sourceBpe , fetcher ) ; Set < String > targets = fetchIDs ( targetBpe , fetcher ) ; SIFType sifType = ( ( SIFMiner ) this ) . getSIFType ( ) ; Set < SIFInteraction > set = new HashSet < SIFInteraction > ( ) ; for ( String source : sources ) { for ( String target : targets ) { if ( source . equals ( target ) ) continue ; else if ( sifType . isDirected ( ) || source . compareTo ( target ) < 0 ) { set . add ( new SIFInteraction ( source , target , sourceBpe , targetBpe , sifType , new HashSet < BioPAXElement > ( m . get ( getMediatorLabels ( ) , getPattern ( ) ) ) , new HashSet < BioPAXElement > ( m . get ( getSourcePELabels ( ) , getPattern ( ) ) ) , new HashSet < BioPAXElement > ( m . get ( getTargetPELabels ( ) , getPattern ( ) ) ) ) ) ; } else { set . add ( new SIFInteraction ( target , source , targetBpe , sourceBpe , sifType , new HashSet < BioPAXElement > ( m . get ( getMediatorLabels ( ) , getPattern ( ) ) ) , new HashSet < BioPAXElement > ( m . get ( getTargetPELabels ( ) , getPattern ( ) ) ) , new HashSet < BioPAXElement > ( m . get ( getSourcePELabels ( ) , getPattern ( ) ) ) ) ) ; } } } return set ; } | Creates a SIF interaction for the given match . |
6,278 | protected Set < String > getIdentifiers ( Match m , String label ) { BioPAXElement el = m . get ( label , getPattern ( ) ) ; if ( idFetcher != null ) return idFetcher . fetchID ( el ) ; Set < String > set = new HashSet < String > ( ) ; if ( el instanceof ProteinReference ) { set . add ( getGeneSymbol ( ( ProteinReference ) el ) ) ; } else if ( el instanceof SmallMoleculeReference ) { set . add ( getCompoundName ( ( SmallMoleculeReference ) el ) ) ; } return set ; } | Uses uniprot name or gene symbol as identifier . |
6,279 | public void update ( LGraphObject lGraphObj ) { if ( lGraphObj instanceof CoSEGraph ) { return ; } LNode lNode = ( LNode ) lGraphObj ; this . glyph . getBbox ( ) . setX ( ( float ) lNode . getLeft ( ) ) ; this . glyph . getBbox ( ) . setY ( ( float ) lNode . getTop ( ) ) ; this . placeStateAndInfoGlyphs ( ) ; } | Function that will take place when VNode objects will update in layout process of ChiLay |
6,280 | public void setBounds ( float w , float h ) { this . glyph . getBbox ( ) . setW ( w ) ; this . glyph . getBbox ( ) . setH ( h ) ; } | Sets the bound of this VNode by given width and height |
6,281 | public void setSizeAccordingToClass ( ) { String glyphClass = this . glyph . getClazz ( ) ; if ( glyphClass . equalsIgnoreCase ( NONE ) ) return ; if ( glyphClass . equalsIgnoreCase ( SOURCE_AND_SINK ) ) { setBounds ( SOURCE_AND_SINK_BOUND . getWidth ( ) , SOURCE_AND_SINK_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( AND ) || glyphClass . equalsIgnoreCase ( OR ) || glyphClass . equalsIgnoreCase ( NOT ) ) { setBounds ( LOGICAL_OPERATOR_BOUND . getWidth ( ) , LOGICAL_OPERATOR_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( ASSOCIATION ) || glyphClass . equalsIgnoreCase ( DISSOCIATION ) || glyphClass . equalsIgnoreCase ( OMITTED_PROCESS ) || glyphClass . equalsIgnoreCase ( UNCERTAIN_PROCESS ) || glyphClass . equalsIgnoreCase ( PROCESS ) ) { setBounds ( PROCESS_NODES_BOUND . getWidth ( ) , PROCESS_NODES_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( SIMPLE_CHEMICAL ) ) { setBounds ( SIMPLE_CHEMICAL_BOUND . getWidth ( ) , SIMPLE_CHEMICAL_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( UNSPECIFIED_ENTITY ) ) { setBounds ( UNSPECIFIED_ENTITY_BOUND . getWidth ( ) , UNSPECIFIED_ENTITY_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( MACROMOLECULE ) ) { setBounds ( MACROMOLECULE_BOUND . getWidth ( ) , MACROMOLECULE_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( NUCLEIC_ACID_FEATURE ) ) { setBounds ( NUCLEIC_ACID_FEATURE_BOUND . getWidth ( ) , NUCLEIC_ACID_FEATURE_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( STATE_VARIABLE ) ) { setBounds ( STATE_BOUND . getWidth ( ) , STATE_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( UNIT_OF_INFORMATION ) ) { setBounds ( INFO_BOUND . getWidth ( ) , INFO_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( PHENOTYPE ) ) { setBounds ( PHENOTYPE_BOUND . getWidth ( ) , PHENOTYPE_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( PERTURBING_AGENT ) ) { setBounds ( PERTURBING_AGENT_BOUND . getWidth ( ) , PERTURBING_AGENT_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( TAG ) ) { setBounds ( TAG_BOUND . getWidth ( ) , TAG_BOUND . getHeight ( ) ) ; } else if ( glyphClass . equalsIgnoreCase ( COMPLEX ) ) { setBounds ( COMPLEX_BOUND . getWidth ( ) , COMPLEX_BOUND . getHeight ( ) ) ; } if ( this . glyph . getClone ( ) != null ) { Bbox glyphBbox = this . glyph . getBbox ( ) ; setBounds ( 3 * glyphBbox . getW ( ) / 4 , 3 * glyphBbox . getH ( ) / 4 ) ; } if ( glyphClass . equalsIgnoreCase ( MACROMOLECULE ) || glyphClass . equalsIgnoreCase ( NUCLEIC_ACID_FEATURE ) || glyphClass . equalsIgnoreCase ( SIMPLE_CHEMICAL ) || glyphClass . equalsIgnoreCase ( COMPLEX ) ) { updateSizeForStateAndInfo ( ) ; } } | Chooses a proper bound for this VNode according to its class . |
6,282 | public int calcReqWidthByStateAndInfos ( List < Glyph > stateORinfoList ) { int wholeSize = 0 ; int count = 0 ; for ( Glyph tmpGlyph : stateORinfoList ) { String text ; if ( tmpGlyph . getState ( ) != null ) { text = tmpGlyph . getState ( ) . getValue ( ) ; if ( tmpGlyph . getState ( ) . getVariable ( ) != null && tmpGlyph . getState ( ) . getVariable ( ) . length ( ) > 0 ) { if ( tmpGlyph . getState ( ) . getVariable ( ) != null ) text += "@" + tmpGlyph . getState ( ) . getVariable ( ) ; } } else if ( tmpGlyph . getLabel ( ) != null ) { text = tmpGlyph . getLabel ( ) . getText ( ) ; } else { throw new RuntimeException ( "Encountered an information glyph with no state " + "variable (as modification boxes should have) and no label (as molecule type " + "boxed should have). glyph = " + tmpGlyph ) ; } int numOfUpper = 0 ; int numOfLower = 0 ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { if ( Character . isLowerCase ( text . charAt ( i ) ) ) { numOfLower ++ ; } else numOfUpper ++ ; } Bbox b = new Bbox ( ) ; tmpGlyph . setBbox ( b ) ; float requiredSize = numOfLower * LOWERCASE_LETTER_PIXEL_WIDTH + numOfUpper * UPPERCASE_LETTER_PIXEL_WIDTH ; if ( requiredSize < MAX_STATE_AND_INFO_WIDTH ) tmpGlyph . getBbox ( ) . setW ( requiredSize ) ; else tmpGlyph . getBbox ( ) . setW ( STATE_BOUND . width ) ; tmpGlyph . getBbox ( ) . setH ( MAX_STATE_AND_INFO_HEIGHT ) ; if ( count < MAX_INFO_BOX_NUMBER / 2 ) wholeSize += tmpGlyph . getBbox ( ) . getW ( ) ; count ++ ; } return wholeSize ; } | Calculates required width according to the given list state and info glyphs of this VNode . This method also previously computes the width and height of state and info glyphs according to their label . |
6,283 | public void updateSizeForStateAndInfo ( ) { for ( Glyph glyph : this . glyph . getGlyph ( ) ) { if ( glyph . getClazz ( ) == STATE_VARIABLE ) { stateGlyphs . add ( glyph ) ; } else if ( glyph . getClazz ( ) == UNIT_OF_INFORMATION ) { infoGlyphs . add ( glyph ) ; } } int wholeWidthOfStates = calcReqWidthByStateAndInfos ( stateGlyphs ) ; int wholeWidthOfInfos = calcReqWidthByStateAndInfos ( infoGlyphs ) ; int numOfStates = stateGlyphs . size ( ) ; int numOfInfos = infoGlyphs . size ( ) ; int totNumStateInfo = numOfInfos + numOfStates ; int multiplier = totNumStateInfo <= 2 ? 2 : 3 ; float requiredWidth = multiplier * OFFSET_BTW_INFO_GLYPHS + ( multiplier - 1 ) * MAX_STATE_AND_INFO_WIDTH ; if ( totNumStateInfo > 0 ) this . glyph . getBbox ( ) . setH ( this . glyph . getBbox ( ) . getH ( ) + MAX_STATE_AND_INFO_HEIGHT / 2 ) ; if ( this . glyph . getBbox ( ) . getW ( ) < requiredWidth ) { this . glyph . getBbox ( ) . setW ( requiredWidth ) ; } } | If glyph attribute of this VNode object includes any state of information or unit of information glyphs this method updates the size of VNode accordingly . |
6,284 | public Set < GraphObject > run ( ) { Set < GraphObject > queryResult = new HashSet < GraphObject > ( ) ; if ( direction == Direction . UPSTREAM || direction == Direction . BOTHSTREAM ) { BFS bfsBackward = new BFS ( sourceNodes , null , Direction . UPSTREAM , this . limit ) ; Map < GraphObject , Integer > mapBackward = bfsBackward . run ( ) ; queryResult . addAll ( mapBackward . keySet ( ) ) ; } if ( direction == Direction . DOWNSTREAM || direction == Direction . BOTHSTREAM ) { BFS bfsForward = new BFS ( sourceNodes , null , Direction . DOWNSTREAM , this . limit ) ; Map < GraphObject , Integer > mapForward = bfsForward . run ( ) ; queryResult . addAll ( mapForward . keySet ( ) ) ; } return queryResult ; } | Executes the query . |
6,285 | private void add ( Constraint constr , int ... ind ) { assert ind . length > 0 ; assert constr . getVariableSize ( ) == ind . length ; for ( int i = 0 ; i < ( constr . canGenerate ( ) ? ind . length - 1 : ind . length ) ; i ++ ) { assert ind [ i ] <= lastIndex ; } constraints . add ( new MappedConst ( constr , ind ) ) ; if ( constr . canGenerate ( ) && ind [ ind . length - 1 ] > lastIndex ) { if ( ind [ ind . length - 1 ] - lastIndex > 1 ) throw new IllegalArgumentException ( "Generated index too large. Attempting to generate index " + ind [ ind . length - 1 ] + " while last index is " + lastIndex ) ; else lastIndex ++ ; } } | Creates a mapped constraint with the given constraint and the indexes it applies . |
6,286 | public void removeLastConstraint ( ) { if ( constraints . isEmpty ( ) ) return ; MappedConst mc = constraints . get ( constraints . size ( ) - 1 ) ; constraints . remove ( mc ) ; if ( mc . canGenerate ( ) && mc . getInds ( ) [ mc . getInds ( ) . length - 1 ] == lastIndex ) { setLastIndexToMaxFound ( ) ; } } | Removes the last constraint added to the pattern . |
6,287 | private void setLastIndexToMaxFound ( ) { int max = - 1 ; for ( MappedConst mc : constraints ) { int [ ] ind = mc . getInds ( ) ; int last = ind [ ind . length - 1 ] ; if ( last > max ) max = last ; } lastIndex = max ; } | This method is used after removal of an generative constraint . Searching the remaining constraints we decide the value of lastIndex . |
6,288 | public void add ( Constraint constr , String ... label ) { checkLabels ( constr . canGenerate ( ) , label ) ; int [ ] ind = convertLabelsToInds ( label ) ; if ( ind . length != constr . getVariableSize ( ) ) { throw new IllegalArgumentException ( "Mapped elements do not match the constraint size." ) ; } add ( constr , ind ) ; if ( ! hasLabel ( label [ label . length - 1 ] ) && constr . canGenerate ( ) ) { label ( label [ label . length - 1 ] , lastIndex ) ; } } | Creates a mapped constraint with the given generative constraint and the indexes it applies . Also labels the last given index . |
6,289 | private int [ ] convertLabelsToInds ( String ... label ) { int [ ] ind = new int [ label . length ] ; for ( int i = 0 ; i < label . length ; i ++ ) { if ( hasLabel ( label [ i ] ) ) { ind [ i ] = indexOf ( label [ i ] ) ; } else ind [ i ] = lastIndex + 1 ; } return ind ; } | Converts the labels to the indexes . Assumes the sanity of the labels already checked and if any new label exists it is only one and it is the last one . |
6,290 | private String [ ] convertIndsToLabels ( int ... ind ) { String [ ] label = new String [ ind . length ] ; for ( int i = 0 ; i < ind . length ; i ++ ) { if ( ! hasLabel ( ind [ i ] ) ) throw new IllegalArgumentException ( "The index " + ind [ i ] + " does not have a label." ) ; label [ i ] = getLabel ( ind [ i ] ) ; } return label ; } | Converts the indices to the labels . All indices must have an existing label . |
6,291 | public void add ( Pattern p ) { if ( ! hasLabel ( p . getLabel ( 0 ) ) ) throw new IllegalArgumentException ( "The label of first " + "element of parameter index \"" + p . getLabel ( 0 ) + "\" not found in this pattern." ) ; for ( MappedConst mc : p . getConstraints ( ) ) { add ( mc . getConstr ( ) , p . convertIndsToLabels ( mc . getInds ( ) ) ) ; } } | Appends the constraints in the parameter pattern to the desired location . Indexes in the constraint mappings are translated so that 0 is translated to ind0 and others are translated to orig + indAppend - 1 . All slots of this pattern should already be full before calling this method . This method makes room for the new variables . Labels in the parameter pattern is transferred to this pattern . If there are equivalent labels then these slots are mapped . |
6,292 | private String getLabel ( int i ) { for ( String label : labelMap . keySet ( ) ) { if ( labelMap . get ( label ) == i ) return label ; } return null ; } | Gets the label for the element at the specified index . |
6,293 | public void insertPointConstraint ( Constraint con , int ... ind ) { assert con . getVariableSize ( ) == 1 ; for ( int i : ind ) { for ( int j = 0 ; j < constraints . size ( ) ; j ++ ) { int [ ] index = constraints . get ( j ) . getInds ( ) ; if ( index [ index . length - 1 ] == i ) { constraints . add ( j + 1 , new MappedConst ( con , i ) ) ; break ; } } } } | A point constraint deals with only one element in a match checks its validity . This method injects the parameter constraint multiple times among the list of mapped constraints to the specified indexes . |
6,294 | public void label ( String labelText , int index ) { if ( labelMap . containsKey ( labelText ) ) throw new IllegalArgumentException ( "Label \"" + labelText + "\" already exists." ) ; if ( labelMap . containsValue ( index ) ) throw new IllegalArgumentException ( "Index \"" + index + "\" already has a label." ) ; labelMap . put ( labelText , index ) ; } | Puts the given label for the given index . |
6,295 | public int indexOf ( String labelText ) { if ( ! labelMap . containsKey ( labelText ) ) throw new IllegalArgumentException ( "The label \"" + labelText + "\" is absent in pattern." ) ; return labelMap . get ( labelText ) ; } | Gets the index of the given label . The label must exist otherwise a runtime exception is thrown . |
6,296 | public void updateLabel ( String oldLabel , String newLabel ) { if ( hasLabel ( newLabel ) ) throw new IllegalArgumentException ( "The label \"" + newLabel + "\" already exists." ) ; int i = indexOf ( oldLabel ) ; labelMap . remove ( oldLabel ) ; labelMap . put ( newLabel , i ) ; } | Changes a label . The oldLabel has to be an existing label and new label has to be a new label . |
6,297 | public static void main ( String [ ] args ) throws IllegalAccessException , InvocationTargetException { for ( String arg : args ) { log . info ( arg ) ; if ( arg . toLowerCase ( ) . endsWith ( "owl" ) ) { try { processXrefs ( arg ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } } } | args - a space seperated list of owl files to be processed |
6,298 | private static void processXrefs ( String arg ) throws FileNotFoundException , IllegalAccessException , InvocationTargetException { FileInputStream in = new FileInputStream ( new File ( arg ) ) ; Model level2 = reader . convertFromOWL ( in ) ; Set < unificationXref > unis = level2 . getObjects ( unificationXref . class ) ; Set < unificationXref > gos = new HashSet < unificationXref > ( ) ; for ( unificationXref uni : unis ) { log . trace ( uni . getDB ( ) ) ; if ( uni . getDB ( ) . equalsIgnoreCase ( "GO" ) ) { log . info ( "scheduling " + uni . getUri ( ) ) ; gos . add ( uni ) ; } } for ( unificationXref go : gos ) { convert ( go , level2 ) ; } reader . convertToOWL ( level2 , new FileOutputStream ( arg . substring ( 0 , arg . lastIndexOf ( '.' ) ) + "-converted.owl" ) ) ; } | Main conversion method . Demonstrates how to read and write a BioPAX model and accessing its objects . |
6,299 | private static void convert ( unificationXref uni , Model level2 ) { Set < XReferrable > referrables = new HashSet < XReferrable > ( uni . isXREFof ( ) ) ; relationshipXref relationshipXref = level2 . addNew ( relationshipXref . class , uni . getUri ( ) ) ; relationshipXref . setCOMMENT ( uni . getCOMMENT ( ) ) ; relationshipXref . setDB ( uni . getDB ( ) ) ; relationshipXref . setDB_VERSION ( uni . getDB_VERSION ( ) ) ; relationshipXref . setID ( uni . getID ( ) ) ; relationshipXref . setID_VERSION ( uni . getID_VERSION ( ) ) ; relationshipXref . setRELATIONSHIP_TYPE ( "http://www.biopax.org/paxtools/convertedGOUnificationXREF" ) ; for ( XReferrable referrable : referrables ) { referrable . addXREF ( relationshipXref ) ; } for ( XReferrable referrable : referrables ) { referrable . removeXREF ( uni ) ; } level2 . remove ( uni ) ; } | This method converts the given unification xref to a relationship xref |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.