#!/usr/bin/perl -w use strict; my $numArgs = $#ARGV + 1; # calculate number of arguments passed to program from command line our $inputfile; our $outputdir; # initialise filename variables if ($numArgs >= 2) { $inputfile = "$ARGV[0]"; print "Input filename received from command line. Opening '$inputfile'...\n"; open INPUTFILE, "<$inputfile" || die "An error occured whilst opening your input file '$inputfile': $!"; $outputdir = "$ARGV[1]"; print "Output directory received from command line...\n"; #open OUTPUTFILE, ">$outputfile" || die "An error occured whilst creating your output file '$outputfile': $!"; } elsif ($numArgs == 1) { $inputfile = "$ARGV[0]"; print "Input filename received from command line. Opening '$inputfile'...\n"; open INPUTFILE, "<$inputfile" || die "An error occured whilst opening your input file '$inputfile': $!"; print "Please enter the path to your output directory: "; chomp($outputdir = ); #open OUTPUTFILE, ">$outputfile" || die "An error occured whilst creating your output file '$outputfile': $!"; } else { print "Please enter the path to your input file: "; chomp($inputfile = ); open INPUTFILE, "<$inputfile" || die "An error occured whilst opening your input file '$inputfile': $!"; print "Please enter the output directory: "; chomp($outputdir = ); #open OUTPUTFILE, ">$outputfile" || die "An error occured whilst creating your output file '$outputfile': $!"; } print "INPUT: $inputfile\n"; print "OUTPUT DIRECTORY: $outputdir\n"; #display input and output file names my $lineindex = 0; while(defined(my $line = )) { # read through each line in turn while they still exist $line =~ s/["]+//g; # remove quotation marks from SMILES strings $line =~ s/[\n]+//g; # remove new line characters my $molconvert_input = "./$outputdir/smiles/molconvert_input$lineindex.smi"; open OUTPUTFILE, "> $molconvert_input" || die "An error occured whilst creating your output file '$molconvert_input': $!"; print OUTPUTFILE "$line\n"; # add new line character as all the fields in this row have been printed my $molconvert_output = "./$outputdir/sdf/molconvert_output$lineindex.sdf"; system "molconvert -F \"-3:[hydrogenize]\" sdf $molconvert_input -o $molconvert_output"; my $xedex_output = "./$outputdir/sdf_xedex/xedex_output$lineindex.sdf"; my $xedex_input = $molconvert_output; system "xedex $xedex_input > $xedex_output"; my $sdftoxed_output = "./$outputdir/xed/sdftoxed_output$lineindex.xed"; my $sdftoxed_input = $xedex_output; system "sdf_to_xed -F $xedex_output > $sdftoxed_output"; $lineindex++; # increment current line } close OUTPUTFILE; #print "molconvert -F '-3:[hydrogenize]' sdf $inputfile -o $outputfile";