def main(): args = parse_arguments() print('Read from {}'.format(args.infile)) print('Write to {}'.format(args.outfile)) suppl = create_mol_supplier(args.infile) if not suppl: print('ERROR - unrecognised file format for {}'.format(infile)) exit(1) with open(args.outfile, 'w') as of: for mol in suppl: if args.fptype == 'Morgan': fp = GetMorganFingerprintAsBitVect(mol, args.size, nBits=args.numbits) elif args.fptype == 'Path': fp = RDKFingerprint(mol, fpSize=args.numbits, maxPath=args.size) of.write('{} {}\n'.format(mol.GetProp('_Name'), DataStructs.BitVectToText(fp)))
def get_maccs_fingerprint_from_mol(m): if m is None: return None k = MACCSkeys.GenMACCSKeys(m) textk = DataStructs.BitVectToText(k) binaryvec = np.array(list(map(int, textk))) return binaryvec
def get_fingerprint(self) : #### Current supported fingerprint is MACCS self.fingerprint_collector['MACCS']=DataStructs.BitVectToText(MACCSkeys.GenMACCSKeys(self.mol))
## minPath=1,maxPath=7,fpSize=2048,nBitsPerHash=4,useHs=True, ## tgtDensity=0.0,minSize=128 ## returns ExplicitBitVect ## ## GenMACCSKeys (no args) ## returns SparseBitVect ## smiA = 'NCCc1cc(O)c(O)cc1' smiB = 'CNC(C)Cc1cc(O)c(O)cc1' molA = Chem.MolFromSmiles(smiA) molB = Chem.MolFromSmiles(smiB) for fper in fpers: fpA = fper(molA) fptxtA = DataStructs.BitVectToText(fpA) print(fptxtA) size = fpA.GetNumBits() count = 0 for i in range(fpA.GetNumBits()): if fpA.GetBit(i): count += 1 print(count, size) if fper == GenMACCSKeys: onbits = tuple(fpA.GetOnBits()) print(str(onbits)) for i in onbits: print(Chem.MACCSkeys.smartsPatts[i][0]) fpB = fper(molB) fptxtB = DataStructs.BitVectToText(fpB) print(fptxtB)