Example #1
0
def merge(b1, b2):
    geneIds = set(typeOps.mkiter(b1.geneIds)) | set(typeOps.mkiter(b2.geneIds))
    b = GeneBoundsBed.create(b1.chrom,
                             min(b1.start, b2.start),
                             max(b1.end, b2.end),
                             b1.name,
                             strand=b1.strand,
                             geneSym=b1.geneSym,
                             hgncId=b1.hgncId,
                             geneIds=list(geneIds),
                             geneType=b1.geneType)
    return b
Example #2
0
 def linkRequires(self, requires):
     """link in productions required by this node. Can be single nodes, or
     lists or sets of nodes, reverse links are created"""
     for r in typeOps.mkiter(requires):
         if not isinstance(r, Production):
             raise ExRunException("Rule " + str(self) + " requires can only be linked to a Production, attempt to link to: " + str(r))
         r.linkRequiredBy(self)
Example #3
0
 def linkProduces(self, produces):
     """link in productions produced by this node. Can be single nodes, or
     lists or sets of nodes, reverse links are created"""
     for p in typeOps.mkiter(produces):
         if not isinstance(p, Production):
             raise ExRunException("Rule " + str(self) + " produces can only be linked to a Production, attempt to link to: " + str(p))
         p.linkProducedBy(self)
Example #4
0
 def __specsToStateTbl(self, notOkSpecs):
     "convert spec lists no tables"
     notOkStates = {}
     for spec in notOkSpecs:
         for n in typeOps.mkiter(spec[0]):
             notOkStates[n] = spec[1]
     return notOkStates
Example #5
0
 def linkRequires(self, requires):
     """link in productions or targets required by this node. Can be single nodes,
     or lists or sets of nodes"""
     for r in typeOps.mkiter(requires):
         if not (isinstance(r, Production) or isinstance(r, Target)):
             raise ExRunException("Target " + str(self) + " requires can only be linked to a Production or a Target, attempt to link to: " + str(r))
         self.requires.add(r)
Example #6
0
 def __addCmdStdio(self, fspecs, specSet, exclude=None):
     "add None, a single or a list of file specs as requires or produces links"
     for fspec in typeOps.mkiter(fspecs):
         if  (isinstance(fspec, FileIn) or isinstance(fspec, FileOut)):
             fspec = fspec.file  # get File object for reference
         if (isinstance(fspec, File) and ((exclude == None) or (fspec not in exclude))):
             specSet.add(fspec)
Example #7
0
 def __specsToStateTbl(self, notOkSpecs):
     "convert spec lists no tables"
     notOkStates = {}
     for spec in notOkSpecs:
         for n in typeOps.mkiter(spec[0]):
             notOkStates[n] = spec[1]
     return notOkStates
Example #8
0
 def __addCmdStdio(self, fspecs, specSet, exclude=None):
     "add None, a single or a list of file specs as requires or produces links"
     for fspec in typeOps.mkiter(fspecs):
         if (isinstance(fspec, FileIn) or isinstance(fspec, FileOut)):
             fspec = fspec.file  # get File object for reference
         if (isinstance(fspec, File)
                 and ((exclude == None) or (fspec not in exclude))):
             specSet.add(fspec)
Example #9
0
 def linkRequiredBy(self, requiredBy):
     """link to rules that require production, can be single rule, lists or
     sets of rules, reverse links are created"""
     for r in typeOps.mkiter(requiredBy):
         if not isinstance(r, Rule):
             raise ExRunException("Production " + str(self) + " requiredBy can only be linked to a Rule, attempt to link to: " + str(r))
         self.requiredBy.add(r)
         r.requires.add(self);
Example #10
0
 def getFiles(self, paths):
     """like getFile(), only path can be a single path, or a list of paths,
     or a File object, or list of File objects.  Returns a list of File
     objects"""
     files = []
     for p in typeOps.mkiter(paths):
         files.append(self.getFile(p))
     return files
Example #11
0
 def getFiles(self, paths):
     """like getFile(), only path can be a single path, or a list of paths,
     or a File object, or list of File objects.  Returns a list of File
     objects"""
     files = []
     for p in typeOps.mkiter(paths):
         files.append(self.getFile(p))
     return files
Example #12
0
 def linkRequires(self, requires):
     """link in productions or targets required by this node. Can be single nodes,
     or lists or sets of nodes"""
     for r in typeOps.mkiter(requires):
         if not (isinstance(r, Production) or isinstance(r, Target)):
             raise ExRunException(
                 "Target " + str(self) +
                 " requires can only be linked to a Production or a Target, attempt to link to: "
                 + str(r))
         self.requires.add(r)
Example #13
0
 def linkRequires(self, requires):
     """link in productions required by this node. Can be single nodes, or
     lists or sets of nodes, reverse links are created"""
     for r in typeOps.mkiter(requires):
         if not isinstance(r, Production):
             raise ExRunException(
                 "Rule " + str(self) +
                 " requires can only be linked to a Production, attempt to link to: "
                 + str(r))
         r.linkRequiredBy(self)
Example #14
0
 def linkProduces(self, produces):
     """link in productions produced by this node. Can be single nodes, or
     lists or sets of nodes, reverse links are created"""
     for p in typeOps.mkiter(produces):
         if not isinstance(p, Production):
             raise ExRunException(
                 "Rule " + str(self) +
                 " produces can only be linked to a Production, attempt to link to: "
                 + str(p))
         p.linkProducedBy(self)
Example #15
0
 def __getRunTargets(self, targets=None):
     "get list of targets to run, return the default if none specified"
     ts = []
     for t in typeOps.mkiter(targets):
         if isinstance(t, Target):
             ts.append(t)
         else:
             ts.append(self.getTarget(t))
     if len(ts) == 0:
         ts.append(self.getTarget(self.defaultTargetName))
     return ts
Example #16
0
 def linkRequiredBy(self, requiredBy):
     """link to rules that require production, can be single rule, lists or
     sets of rules, reverse links are created"""
     for r in typeOps.mkiter(requiredBy):
         if not isinstance(r, Rule):
             raise ExRunException(
                 "Production " + str(self) +
                 " requiredBy can only be linked to a Rule, attempt to link to: "
                 + str(r))
         self.requiredBy.add(r)
         r.requires.add(self)
Example #17
0
 def __getRunTargets(self, targets=None):
     "get list of targets to run, return the default if none specified"
     ts = []
     for t in typeOps.mkiter(targets):
         if isinstance(t, Target):
             ts.append(t)
         else:
             ts.append(self.getTarget(t))
     if len(ts) == 0:
         ts.append(self.getTarget(self.defaultTargetName))
     return ts
Example #18
0
def geneBoundsBigBedRead(bigBedFh, chrom, start, end):
    if start >= end:
        return iter(())
    for entry in typeOps.mkiter(bigBedFh.entries(chrom, start, end)):
        data = entry[2].split('\t')
        yield GeneBoundsBed.create(chrom,
                                   entry[0],
                                   entry[1],
                                   data[0],
                                   score=data[1],
                                   strand=data[2],
                                   thickStart=data[3],
                                   thickEnd=data[4],
                                   itemRgb=data[5],
                                   geneSym=data[6],
                                   hgncId=data[7],
                                   geneIds=data[8],
                                   geneType=data[9])