<commit_before>use strict;
use Data::Dumper;
use Carp;

=head1 NAME

net_build_internal_network - build an internally connected neighbor network with strength cut-off

=head1 SYNOPSIS

net_build_internal_network_limited_by_strength [--url=http://kbase.us/services/networks] dataset_ids edge_types cut_off < query_entity_ids

=head1 DESCRIPTION

Build an internal network given the list of dataset, edge types, and entity ids with the edge strength above cut-off threshold.

=head2 Documentation for underlying call

Returns an "internal" network constructed basing on a given list of datasets with the edge strength above cut-off threshold. Internal network contains the only nodes defined by the geneIds parameter, and edges representing interactions between these nodes.  Only interactions of given types are considered.    

list<string> datasetIds
List of dataset identifiers to be used for building a network

list<string> geneIds
Identifiers of genes of interest for building a network         
                
list<EdgeType> edgeTypes
List of possible edge types to be considered for building a network

=head1 OPTIONS

=over 6

=item B<-u> I<[http://kbase.us/services/networks]> B<--url>=I<[http://kbase.us/services/networks]>
the service url

=item B<-h> B<--help>
prints help information

=item B<--version>
print version information

=back

=head1 EXAMPLE

 echo "kb|g.3899.locus.2366 kb|g.3899.locus.2366" | net_build_internal_network_limited_by_strength "kb|netdataset.plant.cn.7,kb|netdataset.plant.fn.25" "GENE_GENE" 0.8
 net_build_internal_network_limited_by_strength --help
 net_build_internal_network_limited_by_strength --version

=head1 VERSION

1.0

=cut


use Getopt::Long;
use Bio::KBase::KBaseNetworksService::Client;

my $usage = "Usage: net_build_internal_network_limited_by_strength [--url=http://kbase.us/services/networks] dataset_ids edge_types cut_off < query_entity_ids\n";

my $url       = "http://kbase.us/services/networks";
my $help       = 0;
my $version    = 0;

GetOptions("help"       => \$help,
           "version"    => \$version,
           "url=s"     => \$url) or die $usage;

if($help)
{
    print "$usage\n";
    print "\n";
    print "General options\n";
    print "\t--url=[http://kbase.us/services/networks]\t\tthe service url\n";
    print "\t--help\t\tprint help information\n";
    print "\t--version\t\tprint version information\n";
    print "\tdataset_ids=[xxx,yyy,zzz,...]\t\tdataset id list(comma separated)\n";
    print "\tedge_types=[xxx,yyy,zzz,...]\t\tinterested edge types(comma separated)\n";
    print "\tcut_off=xx.yy\t\tedge strength cut off threshold\n";
    print "\n";
    print "Examples: \n";
    print "echo 'kb|g.3899.locus.10 kb|g.3899.locus.11' | net_build_internal_network_limited_by_strength 'kb|netdataset.plant.fn.25,kb|netdataset.plant.cn.6' 'GENE_GENE'\n";
    print "\n";
    print "net_build_internal_network_limited_by_strength --help\tprint out help\n";
    print "\n";
    print "net_build_internal_network_limited_by_strength --version\tprint out version information\n";
    print "\n";
    print "Report bugs to <EMAIL>\n";
    exit(0);
}

if($version)
{
    print "net_build_internal_network_limited_by_strength version 1.0\n";
    print "Copyright (C) 2012 KBase Network Team\n";
    print "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n";
    print "This is free software: you are free to change and redistribute it.\n";
    print "There is NO WARRANTY, to the extent permitted by law.\n";
    print "\n";
    print "Written by <NAME>\n";
    exit(0);
}

die $usage unless @ARGV == 3;
my $dataset_ids = $ARGV[0];
my $edge_types = $ARGV[1];
my $cutOff = $ARGV[2];

my $oc = Bio::KBase::KBaseNetworksService::Client->new($url);
my $input = <STDIN>;
my @datasetIds = split/,/, $dataset_ids;
my @edgeTypes = split/,/, $edge_types;
my @input = <STDIN>;
my $istr = join(" ", @input);
$istr =~ s/[,]/ /g;
@input = split /\s+/, $istr;
my $results = $oc->buildInternalNetworkLimitedByStrength(\@datasetIds, \@input, \@edgeTypes, $cutOff);
my %nodes = ();
foreach my $hr (@{$results->{'nodes'}}) {<commit_msg>Fixed a bug line in build internal network limited by strength script<commit_after>use strict;
use Data::Dumper;
use Carp;

=head1 NAME

net_build_internal_network - build an internally connected neighbor network with strength cut-off

=head1 SYNOPSIS

net_build_internal_network_limited_by_strength [--url=http://kbase.us/services/networks] dataset_ids edge_types cut_off < query_entity_ids

=head1 DESCRIPTION

Build an internal network given the list of dataset, edge types, and entity ids with the edge strength above cut-off threshold.

=head2 Documentation for underlying call

Returns an "internal" network constructed basing on a given list of datasets with the edge strength above cut-off threshold. Internal network contains the only nodes defined by the geneIds parameter, and edges representing interactions between these nodes.  Only interactions of given types are considered.    

list<string> datasetIds
List of dataset identifiers to be used for building a network

list<string> geneIds
Identifiers of genes of interest for building a network         
                
list<EdgeType> edgeTypes
List of possible edge types to be considered for building a network

=head1 OPTIONS

=over 6

=item B<-u> I<[http://kbase.us/services/networks]> B<--url>=I<[http://kbase.us/services/networks]>
the service url

=item B<-h> B<--help>
prints help information

=item B<--version>
print version information

=back

=head1 EXAMPLE

 echo "kb|g.3899.locus.2366 kb|g.3899.locus.2366" | net_build_internal_network_limited_by_strength "kb|netdataset.plant.cn.7,kb|netdataset.plant.fn.25" "GENE_GENE" 0.8
 net_build_internal_network_limited_by_strength --help
 net_build_internal_network_limited_by_strength --version

=head1 VERSION

1.0

=cut


use Getopt::Long;
use Bio::KBase::KBaseNetworksService::Client;

my $usage = "Usage: net_build_internal_network_limited_by_strength [--url=http://kbase.us/services/networks] dataset_ids edge_types cut_off < query_entity_ids\n";

my $url       = "http://kbase.us/services/networks";
my $help       = 0;
my $version    = 0;

GetOptions("help"       => \$help,
           "version"    => \$version,
           "url=s"     => \$url) or die $usage;

if($help)
{
    print "$usage\n";
    print "\n";
    print "General options\n";
    print "\t--url=[http://kbase.us/services/networks]\t\tthe service url\n";
    print "\t--help\t\tprint help information\n";
    print "\t--version\t\tprint version information\n";
    print "\tdataset_ids=[xxx,yyy,zzz,...]\t\tdataset id list(comma separated)\n";
    print "\tedge_types=[xxx,yyy,zzz,...]\t\tinterested edge types(comma separated)\n";
    print "\tcut_off=xx.yy\t\tedge strength cut off threshold\n";
    print "\n";
    print "Examples: \n";
    print "echo 'kb|g.3899.locus.10 kb|g.3899.locus.11' | net_build_internal_network_limited_by_strength 'kb|netdataset.plant.fn.25,kb|netdataset.plant.cn.6' 'GENE_GENE'\n";
    print "\n";
    print "net_build_internal_network_limited_by_strength --help\tprint out help\n";
    print "\n";
    print "net_build_internal_network_limited_by_strength --version\tprint out version information\n";
    print "\n";
    print "Report bugs to <EMAIL>\n";
    exit(0);
}

if($version)
{
    print "net_build_internal_network_limited_by_strength version 1.0\n";
    print "Copyright (C) 2012 KBase Network Team\n";
    print "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n";
    print "This is free software: you are free to change and redistribute it.\n";
    print "There is NO WARRANTY, to the extent permitted by law.\n";
    print "\n";
    print "Written by <NAME>\n";
    exit(0);
}

die $usage unless @ARGV == 3;
my $dataset_ids = $ARGV[0];
my $edge_types = $ARGV[1];
my $cutOff = $ARGV[2];

my $oc = Bio::KBase::KBaseNetworksService::Client->new($url);
my @datasetIds = split/,/, $dataset_ids;
my @edgeTypes = split/,/, $edge_types;
my @input = <STDIN>;
my $istr = join(" ", @input);
$istr =~ s/[,]/ /g;
@input = split /\s+/, $istr;
my $results = $oc->buildInternalNetworkLimitedByStrength(\@datasetIds, \@input, \@edgeTypes, $cutOff);
my %nodes = ();
foreach my $hr (@{$results->{'nodes'}}) {
{'fraction_non_alphanumeric': 0.13158846942467736, 'fraction_numerical': 0.014955976359908335, 'mean_word_length': 4.087116564417178, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6077236', 'n_tokens_mistral': 2866, 'n_tokens_neox': 2740, 'n_words': 778}