Logical definition to plain OBO file

From DO-Wiki
Jump to: navigation, search

#The following script converts a logical definition file to a regular OBO file
use strict;
use warnings;

#open the logical definition file
open(IN, "<DO_logical_def.obo")
  or die "Couldn't open file for processing: $!";

#open the output file (regular OBO file)
open OUT, ">non_logical_file.obo" or die $!;

#This loop prints out the header information which is at the top of the logical definition file.  Once the first TERM is reached, the loop ends
while (<IN>) {

	if ($_ =~ m/^\[Term\]/)
	print OUT $_;

close IN;

#open the logical definition file again
open(IN2, "<combined1.obo")
  or die "Couldn't open file for processing: $!";

#This flag will be used to indicate the first instance of a DOID id
my $flag = 0;

#print to the output file the word "[TERM] so that the first term will be properly formatted
print OUT "[TERM]\n";

#This loop outputs ID's and relevant information associated with DOID
while (<IN2>) {
  if ($_ =~ m/DOID:/)
	$flag = 1;
  }#Terms that have DOID's are  output 
  if ($flag == 1 && $_ !~ /^intersection_of/)
	print OUT $_;
close IN2;
close OUT;
Personal tools