Example #1
0
 def begin(self):
     self.in_orion = config_from_env() is not None
     if self.in_orion:
         #self.stream = stream_file(988)
         self.stream = stream_file(self.args.data_in)
     else:
         self.stream = open(str(self.args.data_in), 'rb')
    def begin(self):
        if self.args.method == 'Fingerprint':
            fptypes = {102 : 'path', 104 : 'circular', 105 : 'tree'}
            self.FPType = fptypes[self.args.fptype]
            self.name_ext = 'FP_' + self.FPType
        elif self.args.method == 'FastROCS':
            self.name_ext = 'FR'

        self.in_orion = config_from_env() is not None
        if self.in_orion:
            self.stream = tempfile.NamedTemporaryFile()
        else:
            path = self.args.name + "ranking_" + self.name_ext + ".txt"
            self.stream = open(path, 'wb')
Example #3
0
    def __iter__(self):
        max_idx = self.args.limit
        if max_idx is not None:
            max_idx = int(max_idx)
        count = 0
        self.config = config_from_env()
        in_orion = self.config is not None
        if not in_orion:
            with oechem.oemolistream(str(self.args.data_in)) as ifs:
                for mol in ifs.GetOEMols():
                    mol.SetData(oechem.OEGetTag('prefix'), self.opt['prefix'])
                    mol.SetData(oechem.OEGetTag('suffix'), self.opt['suffix'])

                    for at in mol.GetAtoms():
                        residue = oechem.OEAtomGetResidue(at)
                        residue.SetName(self.opt['type'])
                        oechem.OEAtomSetResidue(at, residue)

                    if self.opt['IDTag']:
                        mol.SetData(oechem.OEGetTag('IDTag'), 'l' + mol.GetTitle()[0:12] + '_' + str(count))
                    yield mol
                    count += 1
                    if max_idx is not None and count == max_idx:
                        break
        else:
            stream = StreamingDataset(self.args.data_in,
                                      input_format=self.args.download_format)
            for mol in stream:
                mol.SetData(oechem.OEGetTag('prefix'), self.opt['prefix'])
                mol.SetData(oechem.OEGetTag('suffix'), self.opt['suffix'])

                for at in mol.GetAtoms():
                    residue = oechem.OEAtomGetResidue(at)
                    residue.SetName(self.opt['type'])
                    oechem.OEAtomSetResidue(at, residue)

                if self.opt['IDTag']:
                    mol.SetData(oechem.OEGetTag('IDTag'), 'l' + mol.GetTitle()[0:12] + '_'+str(count))
                yield mol
                count += 1
                if max_idx is not None and count == max_idx:
                    break
Example #4
0
 def __iter__(self):
     max_idx = self.args.limit
     if max_idx is not None:
         max_idx = int(max_idx)
     count = 0
     self.config = config_from_env()
     in_orion = self.config is not None
     if not in_orion:
         with oechem.oemolistream(str(self.args.data_in)) as ifs:
             for mol in ifs.GetOEMols():
                 mol.SetTitle(self.opt['protein_prefix'])
                 yield mol
                 count += 1
                 if max_idx is not None and count == max_idx:
                     break
     else:
         stream = StreamingDataset(self.args.data_in,
                                   input_format=self.args.download_format)
         for mol in stream:
             mol.SetTitle(self.opt['protein_prefix'])
             yield mol
             count += 1
             if max_idx is not None and count == max_idx:
                 break
 def begin(self):
     self.in_orion = config_from_env() is not None
     if self.in_orion:
         self.stream = tempfile.NamedTemporaryFile()
 def begin(self):
     self.in_orion = config_from_env() is not None
     if self.in_orion:
         self.stream = tempfile.NamedTemporaryFile()
     else:
         self.stream = open(self.args.name, 'w')
Example #7
0
    def __iter__(self):
        max_idx = self.args.limit
        if max_idx is not None:
            max_idx = int(max_idx)
        count = 0
        self.config = config_from_env()
        in_orion = self.config is not None
        if not in_orion:
            with oechem.oemolistream(str(self.args.data_in)) as ifs:
                for mol in ifs.GetOEMols():
                    mol.SetTitle(self.opt['protein_prefix'])
                    yield mol
                    count += 1
                    if max_idx is not None and count == max_idx:
                        break
        else:
            stream = StreamingDataset(self.args.data_in,
                                      input_format=self.args.download_format)
            for mol in stream:
                mol.SetTitle(self.opt['protein_prefix'])
                yield mol
                count += 1
                if max_idx is not None and count == max_idx:
                    break


# class SimOutputCube(OEMolOStreamCube):
#     """
#     A sink cube that writes molecules to a file
#     """
#     classification = [["Output"]]
#     title = "Output Writer"
#
#     intake = BinaryMoleculeInputPort('intake')
#     data_out = DataSetOutputParameter('data_out',
#                                       required=True,
#                                       title='Name of Dataset to create',
#                                       description='The dataset to output')
#     backend = DataSetOutputParameter(
#         'backend',
#         default="auto",
#         choices=["db", "s3", "auto"],
#         description="The Orion storage backend to use")
#
#     def begin(self):
#         self.in_orion = config_from_env() is not None
#         self.decoder = MoleculeSerializerMixin()
#         self.need_decode = not self.args.data_out.endswith(".oeb.gz")
#         if self.in_orion:
#             self.ofs = MultipartDatasetUploader(self.args.data_out,
#                                                 tags=[self.name],
#                                                 backend=self.args.backend)
#         elif self.need_decode:
#             self.ofs = oechem.oemolostream(str(self.args.data_out))
#         else:
#             self.ofs = open(str(self.args.data_out), 'wb')
#
#     def write(self, mol, port):
#         if self.in_orion or not self.need_decode:
#             self.ofs.write(mol)
#         else:
#             oechem.OEWriteMolecule(self.ofs, self.decoder.decode(mol))
#
#     def end(self):
#         if self.in_orion:
#             self.ofs.complete()
#         else:
#             self.ofs.close()