コード例 #1
0
parser.add_argument('-o', '--output', type=str, help='MOL2 output file for filtered results.')
parser.add_argument('-c', '--criteria', type=str, help='Query atom and charge ranges e.g., "O.2,-1.2,2;O.3,-20.0,100.0".')
parser.add_argument('-m', '--matchall', action='store_true', help='If flag is provided, molecule must satisfy all criteria.')


args = parser.parse_args()

if not args.input:
    print('Please provide a valid input file. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()
if not args.output:
    print('Please provide a output file path. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()
if not args.criteria:
    print('Please provide some search criteria. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()    
    
clist = create_chargetype_list(group_charge_pairs=args.criteria, atom_list=None)
mmol2 = split_multimol2(multimol2=args.input)

filterfunc = count_matches
if args.matchall:
    filterfunc = match_all

with open(args.output, 'w') as out_file:
    for m in mmol2:
        res = filterfunc(mol2_cont=m[1].split('\n'), chargetype_list=clist)
        if res:
            for line in m[1]:
                out_file.write(line)
            print(m[0])
コード例 #2
0
def test_split_multimol2():
    res = list(split_multimol2(mol2file))
    assert(len(res) == 200)
    assert(res[2][0] == "ZINC00000016_3")
    assert(res[4][1].startswith("@<TRIPOS>MOLECULE") == True)
コード例 #3
0
ファイル: mol2_split.py プロジェクト: asutter88/pyprot
    )

parser.add_argument('-i', '--input', type=str, help='MOL2 input file.')
parser.add_argument('-o', '--output', type=str, help='Output directory for the individual mol2 files.')


args = parser.parse_args()


if not args.input:
    print('Please provide an input file via the -i flag. Use --help for more information.\n') 
    quit()
if not args.output:
    print('Please provide an output file via the -o flag. Use --help for more information.\n') 
    quit()
    


if not os.path.exists(args.output):
    os.mkdir(args.output)

single_mol2s = split_multimol2(args.input)
for mol2 in single_mol2s:
    out_mol2 = os.path.join(args.output, mol2[0]) + '.mol2'
    with open(out_mol2, 'w') as out_file:
        for line in mol2[1]:
            out_file.write(line)



コード例 #4
0
if not args.input2:
    print('Please provide a valid input query file. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()
if not args.output:
    print('Please provide a output file path. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()
if not args.criteria:
    print('Please provide some search criteria. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()
if not args.distance:
    print('Please provide distance criteria. Run ./mol2_filter_funcgroups.py -h for help.')
    quit()        
    
clist = create_chargetype_list(group_charge_pairs=args.criteria, atom_list=None)

reference = split_multimol2(multimol2=args.input1)
reference = next(reference)
ref_cont = reference[1].split('\n')
ref_name = reference[0]

query = split_multimol2(multimol2=args.input2)


with open(args.output, 'w') as out_file:
    for q in query:
        res = intermol_distance_match(
                    mol2_ref=ref_cont, 
                    mol2_query=q[1].split('\n'), 
                    chargetype_list=clist,
                    distance=[0,5]
                    )
コード例 #5
0
args = parser.parse_args()


if not args.input1:
    print('Please provide an input file via the -i1 flag. Use --help for more information.\n') 
    quit()
if not args.input2:
    print('Please provide an input file via the -i2 flag. Use --help for more information.\n') 
    quit()




# get mol2 in line list format
ref_mol2 = split_multimol2(args.input1)
ref_mol2 = next(ref_mol2)[1].split('\n')

fix_mol2 = split_multimol2(args.input2)
fix_mol2 = next(fix_mol2)[1].split('\n')



# apply the charge fix
out_cont = swap_charge(
        template_mol2=ref_mol2,
        target_mol2=fix_mol2,
        template_col=args.reference_column,
        target_col=args.target_column
        )