public static JSONArray JSONArrayOfSubgroupFromJsonArray(JSONArray organizedJson, String key){

		int len = organizedJson.length();
		int i,j,k,l;
		JSONArray json = new JSONArray();
		String subgroup_name;
		boolean ok = false;
		for(i = 0; i < len && !ok; i++)
		{
			JSONArray groups = organizedJson.getJSONObject(i).getJSONArray("groups");
			int leng = groups.length();
			for(j = 0; j < leng && !ok; j++)
			{
				JSONArray subgroups = groups.getJSONObject(j).getJSONArray("subgroups");
				int lens = subgroups.length();
				for(k = 0; k < lens && !ok; k++)
				{
					subgroup_name = subgroups.getJSONObject(k).getString("subgroup");
					if(subgroup_name.equals(key)){
						JSONArray genomes = subgroups.getJSONObject(k).getJSONArray("genomes");
						int lenc = genomes.length();
						for(l = 0; l < lenc && !ok; l++)
						{						
							JSONObject genome = genomes.getJSONObject(l);
							json.put(genome);
						}
						ok = true;
					}
				}
			}
		}
		
		return json;
	}