예제 #1
0
파일: lab3.py 프로젝트: Granoia/bio331-lab3
def main():
    nodes, edges, edge_dict = readData('EGFR1-reachable.txt')
    adj_ls = make_adj_ls(nodes, edges)
    BFS_distances(adj_ls,'EGF')
    
    edgeAttrs = getEdgeAttributes(edges,edge_dict)
    nodeAttrs = getNodeAttributes(nodes, adj_ls)

    #data = json_utils.make_json_data(nodes,edges,nodeAttrs,edgeAttrs,'Lab 3','Desc.',['Tag'])
    #json_utils.write_json(data,'lab3.json')
    #graphspace_utils.postGraph('lab3-2-1','lab3.json','*****@*****.**','bio331')


    hc_nodes, hc_edges = handle_complexes(nodes, edges)
    hc_adj_ls = make_adj_ls(hc_nodes,hc_edges)
    BFS_distances(hc_adj_ls,'EGF')
    hc_edgeAttrs = getEdgeAttributes(hc_edges)
    hc_nodeAttrs = getNodeAttributes(hc_nodes, hc_adj_ls)

    

    
    data2 = json_utils.make_json_data(hc_nodes, hc_edges,hc_nodeAttrs,hc_edgeAttrs,'Lab 3: Handle Complexes','Desc.',['Tag'])
    json_utils.write_json(data2,'lab3-hc.json')
    graphspace_utils.postGraph('lab3-4','lab3-hc.json','*****@*****.**','bio331')
    
    #print(get_int_types(edge_dict))

    print(len(nodes), len(hc_nodes))
    print(len(edges), len(hc_edges))
예제 #2
0
파일: Lab5.py 프로젝트: Granoia/bio331-lab5
def post_graph(nodes, edges, graphid, username, password, d="Lab 5"):
    """
    Gets attributes of graph and posts it to GS.
    """
    nodeAttrs, edgeAttrs = getAttributes(nodes, edges)
    data = json_utils.make_json_data(nodes,edges,nodeAttrs,edgeAttrs, \
        title="Lab5 "+graphid,description=d,tags=['Lab5'])
    json_utils.write_json(data, graphid + '.json')
    graphspace_utils.postGraph(graphid, graphid + '.json', username, password)
    return
예제 #3
0
def main():
    nodes, edges, edge_dict = readData('EGFR1-reachable.txt')
    edgeAttrs = getEdgeAttributes(edges, edge_dict)
    print(get_int_types(edge_dict))

    data = json_utils.make_json_data(nodes, edges, None, edgeAttrs, 'Lab 3',
                                     'Desc.', ['Tag'])
    json_utils.write_json(data, 'lab3StrangeError.json')
    graphspace_utils.postGraph('lab3-2-1', 'lab3.json', '*****@*****.**',
                               'bio331')
예제 #4
0
def upload_graph(nodes, adj_mat,GRAPHID,TITLE,TAGS=0,node_attrs=None,edge_attrs=None):
    """
    uploads the graph to the GraphSpace
    """
    if TAGS == 0:
        tag_ls = []
    else:
        tag_ls = TAGS
    edges = get_undirected_edges(nodes,adj_mat)
    #json_utils.test()
    data = json_utils.make_json_data(nodes,edges,node_attrs,edge_attrs,TITLE,'Desc.',tag_ls)
    json_utils.write_json(data,'hw1.json')
    graphspace_utils.postGraph(GRAPHID,'hw1.json','*****@*****.**','bio331')
예제 #5
0
    las_data_read.close()

    if args.decimation_step != 1:
        xyzc_points = xyzc_points[::args.decimation_step, :]

    all_points = xyzc_points

    if args.floor_threshold >= 0:
        floor_mask = get_floor_mask(xyzc_points, threshold=args.floor_threshold)
        xyzc_points = xyzc_points[floor_mask, :]

    road_mask, roads = get_road_points(xyzc=xyzc_points,
                                       epsg=args.epsg,
                                       cache=args.cache)

    xyzc_points[:, 3] = road_mask

    if args.floor_threshold >= 0:
        all_points[floor_mask, :] = xyzc_points

    if args.roads_out is not None:
        json_utils.write_json(roads, args.roads_out)

    file_out = args.out if args.out is not None else args.las_road_segmenter
    save_las(all_points, las_header, file_out)

    if args.show_result:
        show_las(xyzc_points[:, 0],
                 xyzc_points[:, 1],
                 xyzc_points[:, 2],
                 xyzc_points[:, 3])
예제 #6
0
    def generate(self,
                 out_path="",
                 max_file_points=65000,
                 max_las_files=None,
                 subsample=True):
        out_folder = out_path + self.name
        shutil.rmtree(out_folder, ignore_errors=True)
        os.mkdir(out_folder)

        voxel_indices = []
        bounds = []
        point_classes = []

        files = self.__file_paths
        if max_las_files is not None: files = files[:max_las_files]

        for index, file in enumerate(files):

            index_file_name = "tree_%d.json" % index

            print("Processing file %s" % file)
            in_file = File(file, mode='r')

            lat, lon = pc_utils.convert_las_to_wgs84(in_file.x,
                                                     in_file.y,
                                                     self.epsg_num,
                                                     show_map=False)
            h = in_file.z

            sector = pc_utils.get_sector(lat, lon)
            print("Sector ", end="")
            print(sector)

            xyzc = np.transpose(
                np.array([
                    in_file.x, in_file.y, in_file.z,
                    in_file.Classification.astype(float)
                ]))

            if "xyz_offset" not in locals():
                xyz_offset = np.min(xyzc[:, 0:3], axis=0)

            xyzc[:, 0] -= xyz_offset[0]
            xyzc[:, 1] -= xyz_offset[1]
            xyzc[:, 2] -= xyz_offset[2]

            cs = np.unique(xyzc[:, 3]).tolist()
            point_classes += [c for c in cs if c not in point_classes]

            self.n_generation_points = xyzc.shape[0]
            self.n_generation_stored_points = 0
            print("%d points. %d classes." %
                  (xyzc.shape[0], len(point_classes)))

            vi = self.__save_tree(xyzc, [index],
                                  out_folder=out_folder,
                                  max_points=max_file_points,
                                  subsample=subsample)

            bounds += [vi["min"], vi["max"]]

            voxel_indices += [{
                "file": index_file_name,
                "min": vi["min"],
                "max": vi["max"]
            }]
            json_utils.write_json(vi, out_folder + "/" + index_file_name)

            gc.collect()  # Forcing garbage collection

        bounds = np.array(bounds)
        xyz_min = np.min(bounds, axis=0)
        xyz_max = np.max(bounds, axis=0)

        model = {
            "model_name": self.name,
            "xyz_offset": xyz_offset.tolist(),
            "min": xyz_min.tolist(),
            "max": xyz_max.tolist(),
            "classes": PointCloudModel.__generate_color_palette(point_classes),
            "nodes": voxel_indices
        }

        json_utils.write_json(model, out_folder + "/pc_model.json")
    parser = argparse.ArgumentParser()
    parser.add_argument("overpass_roads", help="Get OSM road information from the Overpass API.", action='store_true')
    parser.add_argument("-minlat", "--min_latitude", help="Minimum Latitude", type=float)
    parser.add_argument("-minlon", "--min_longitude", help="Minimum Longitude", type=float)
    parser.add_argument("-maxlat", "--max_latitude", help="Maximum Latitude", type=float)
    parser.add_argument("-maxlon", "--max_longitude", help="Maximum Longitude", type=float)
    parser.add_argument("-e", "--epsg", help="Output EPSG Projection", type=int, default=4326)
    parser.add_argument("-o", "--out", help="Output JSON File", type=str, default=None)
    parser.add_argument("-c", "--cache", help="Cache File", type=str, default="")
    parser.add_argument("-s", "--show_results",
                        help="Show resulting point cloud",
                        action='store_true')

    args = parser.parse_args()  # getting args
    sector = (args.min_latitude, args.min_longitude, args.max_latitude, args.max_longitude)
    cache = None if args.cache == "" else ObjectCache(args.cache)

    osm_roads = get_roads(sector, cache, epsg_to=args.epsg)

    if args.show_results:
        show_linestrings(osm_roads)

    if args.out is None:
        print(osm_roads)
    else:
        json_utils.write_json(osm_roads, args.out)