<s> import sys , re , os , subprocess , shlex , tempfile , shutil <EOL> def stop_err ( msg ) : <EOL> sys . stderr . write ( '<STR_LIT>' % msg ) <EOL> sys . exit ( ) <EOL> MDS_path = "<STR_LIT>" <EOL> input_full_path = sys . argv [ <NUM_LIT:1> ] <EOL> MDS_genome = sys . argv [ <NUM_LIT:2> ] <EOL> gff3_output = sys . argv [ <NUM_LIT:3> ] <EOL> dataresult = sys . argv [ <NUM_LIT:4> ] <EOL> datacluster = sys . argv [ <NUM_LIT:5> ] <EOL> tmp_MDS_work_dir = tempfile . mkdtemp ( dir = MDS_path ) <EOL> os . symlink ( input_full_path , tmp_MDS_work_dir + "<STR_LIT>" ) <EOL> os . symlink ( MDS_path + "<STR_LIT>" , tmp_MDS_work_dir + "<STR_LIT>" ) <EOL> os . symlink ( MDS_path + "<STR_LIT>" , tmp_MDS_work_dir + "<STR_LIT>" ) <EOL> os . symlink ( MDS_path + "<STR_LIT>" , tmp_MDS_work_dir + "<STR_LIT>" ) <EOL> os . symlink ( MDS_path + "<STR_LIT>" , tmp_MDS_work_dir + "<STR_LIT>" ) <EOL> command_line = "<STR_LIT>" + MDS_path + "<STR_LIT>" + MDS_genome + "<STR_LIT>" <EOL> print command_line <EOL> try : <EOL> os . chdir ( tmp_MDS_work_dir ) <EOL> p = subprocess . Popen ( args = command_line , cwd = tmp_MDS_work_dir , shell = True , stderr = sys . stderr ) <EOL> returncode = p . wait ( ) <EOL> shutil . copy2 ( "<STR_LIT>" , dataresult ) <EOL> shutil . copy2 ( "<STR_LIT>" , datacluster ) <EOL> dataFILE = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> datafile = dataFILE . readlines ( ) <EOL> dataFILE . close ( ) <EOL> GFF3OUT = open ( gff3_output , "<STR_LIT:w>" ) <EOL> print >> GFF3OUT , "<STR_LIT>" <EOL> print >> GFF3OUT , "<STR_LIT>" <EOL> print >> GFF3OUT , "<STR_LIT>" <EOL> for line in datafile [ <NUM_LIT:1> : ] : <EOL> fields = line . split ( "<STR_LIT:\t>" ) <EOL> Seqid , Source , Type , Start , End , Score , Strand , Phase = fields [ <NUM_LIT:2> ] , "<STR_LIT>" , "<STR_LIT>" , fields [ <NUM_LIT:4> ] . split ( "<STR_LIT:->" ) [ <NUM_LIT:0> ] , fields [ <NUM_LIT:4> ] . split ( "<STR_LIT:->" ) [ <NUM_LIT:1> ] , fields [ <NUM_LIT:1> ] , fields [ <NUM_LIT:3> ] , "<STR_LIT:.>" <EOL> ID = "<STR_LIT>" % ( fields [ <NUM_LIT:0> ] , fields [ <NUM_LIT:5> ] , fields [ <NUM_LIT:7> ] , fields [ <NUM_LIT:8> ] , fields [ <NUM_LIT:9> ] ) <EOL> print >> GFF3OUT , "<STR_LIT>" % ( Seqid , Source , Type , Start , End , Score , Strand , Phase , ID ) <EOL> GFF3OUT . close ( ) <EOL> if os . path . exists ( tmp_MDS_work_dir ) : <EOL> shutil . rmtree ( tmp_MDS_work_dir ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> except Exception , e : <EOL> if os . path . exists ( tmp_MDS_work_dir ) : <EOL> shutil . rmtree ( tmp_MDS_work_dir ) <EOL> stop_err ( '<STR_LIT>' + str ( e ) ) </s>
