Takes a folder with feature files in binary format and converts them to text.

@param featuresFolder
@param featureType
@param featureLength
@throws Exception
188662
public static void binaryToText(String featuresFolder, final String featureType, int featureLength)
			throws Exception {
		// read the folder containing the description files
		File dir = new File(featuresFolder);
		FilenameFilter filter = new FilenameFilter() {
			public boolean accept(File dir, String name) {
				if (name.endsWith("." + featureType + "b"))
					return true;
				else
					return false;
			}
		};
		String[] files = dir.list(filter);

		for (int i = 0; i < files.length; i++) {
			if (i % 100 == 0) {
				System.out.println("Converting file " + i);
			}

			DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(
					featuresFolder + files[i])));
			BufferedWriter out = new BufferedWriter(new FileWriter(new File(featuresFolder
					+ files[i].replace("b", ""))));
			long counter = 0;
			while (true) {
				try {
					double val = in.readDouble();
					out.write(String.valueOf(val));
				} catch (EOFException e) {
					break;
				}
				counter++;
				if (counter % featureLength == 0) {
					out.write("\n");
				} else {
					out.write(",");
				}

			}
			in.close();
			out.close();
		}
	}
1317319
public static FeatureCollection fromFeature(@NonNull Feature feature) {
    List<Feature> featureList = Arrays.asList(feature);
    return new FeatureCollection(TYPE, null, featureList);
  }
1200151
protected void processLAandLI(File archive, RepositoryResourceWritable resource,
                                  ProvisioningFeatureDefinition feature) throws IOException, RepositoryException {
        String LAHeader = feature.getHeader(LA_HEADER_FEATURE);
        String LIHeader = feature.getHeader(LI_HEADER_FEATURE);
        processLAandLI(archive, resource, LAHeader, LIHeader);
    }
409661
public function write($path, FeatureNode $feature)
    {
        file_put_contents($this->getCachePathFor($path), serialize($feature));
    }
967608
private void saveFeatureIndexes(FeatureIndex[] index, String outputDir) throws IOException
	{
		logger.info("");

		// save the indexes
		for (int i=0;i<index.length;i++)
		{
			logger.debug("dic" + i + " size " + index[i].size());

			File tmp = new File(outputDir + "dic" + i);
			//File tmp = File.createTempFile("dic" + i, null);
			//tmp.deleteOnExit();

			BufferedWriter bwd = new BufferedWriter(new FileWriter(tmp));
			index[i].write(bwd);
			bwd.close();

			// add the dictionary to the model
			//model.add(tmp, "dic" + i);
		} // end for
	}
42519
public void report(FeatureEnum name, EPUBLocation location, String value)
  {
    features.put(name, new Feature(name, location, value));
  }
1052467
function(features) {
        if(!(OpenLayers.Util.isArray(features))) {
            features = [features];
        }
        var kml = this.createElementNS(this.kmlns, "kml");
        var folder = this.createFolderXML();
        for(var i=0, len=features.length; i<len; ++i) {
            folder.appendChild(this.createPlacemarkXML(features[i]));
        }
        kml.appendChild(folder);
        return OpenLayers.Format.XML.prototype.write.apply(this, [kml]);
    }
529122
function createFeatureList() {
  var header = (0
    + 2 // FeatureCount
    + 4 // FeatureTag[0]
    + 2 // Feature Offset[0]
  );

  var length = (0
    + header
    + 2 // FeatureParams[0]
    + 2 // LookupCount[0]
    + 2 // Lookup[0] LookupListIndex[0]
  );

  var buffer = new ByteBuffer(length);

  // FeatureCount
  buffer.writeUint16(1);
  // FeatureTag[0]
  buffer.writeUint32(identifier('liga'));
  // Feature Offset[0]
  buffer.writeUint16(header);
  // FeatureParams[0]
  buffer.writeUint16(0);
  // LookupCount[0]
  buffer.writeUint16(1);
  // Index into lookup table. Since we only have ligatures, the index is always 0
  buffer.writeUint16(0);

  return buffer;
}
1162449
public void execute() throws MojoExecutionException {

        if (!featuresDirectory.exists()) {
            throw new MojoExecutionException("Features directory does not exist");
        }

        final Collection<File> featureFiles = listFiles(featuresDirectory, new String[] {"feature"}, true);
        final List<File> sortedFeatureFiles = new NameFileComparator().sort(new ArrayList<File>(featureFiles));

        createOutputDirIfRequired();

        File packageDirectory = packageName == null
                ? outputDirectory
                : new File(outputDirectory, packageName.replace('.','/'));

        if (!packageDirectory.exists()) {
            packageDirectory.mkdirs();
        }

        final CucumberITGenerator fileGenerator = createFileGenerator();
        fileGenerator.generateCucumberITFiles(packageDirectory, sortedFeatureFiles);

        getLog().info("Adding " + outputDirectory.getAbsolutePath()
                        + " to test-compile source root");

        project.addTestCompileSourceRoot(outputDirectory.getAbsolutePath());
    }
155014
static public void addGmodGFF3GeneFeatures(LinkedHashMap<String, ChromosomeSequence> chromosomeSequenceList, FeatureList listGenes) throws Exception {


		// key off mRNA as being a known feature that may or may not have a parent gene


		FeatureList mRNAFeatures = listGenes.selectByType("mRNA");
		LinkedHashMap<String,FeatureList> featureIDHashMap = FeatureHelper.buildFeatureAtrributeIndex("ID", listGenes);
		LinkedHashMap<String,FeatureList> featureParentHashMap = FeatureHelper.buildFeatureAtrributeIndex("Parent", listGenes);

		for (FeatureI f : mRNAFeatures) {
			String geneID;
			String geneNote = null;
			String geneSource = null;
			String sequenceName = null;
			ChromosomeSequence seq = null;
			GeneSequence geneSequence = null;

			Feature mRNAFeature = (Feature) f;
			String mRNAID = mRNAFeature.getAttribute("ID");
			String mRNAsource = mRNAFeature.source();
			String mRNANote = mRNAFeature.getAttribute("Note");
			String mRNAParent = mRNAFeature.getAttribute("Parent");
			if (mRNAParent != null && mRNAParent.length() > 0) {
			   // FeatureList geneFeatureList = listGenes.selectByAttribute("ID", mRNAParent);
				FeatureList geneFeatureList = featureIDHashMap.get(mRNAParent);
				Feature geneFeature = (Feature) geneFeatureList.get(0);
				geneID = geneFeature.getAttribute("ID");
				geneNote = geneFeature.getAttribute("Note");
				geneSource = geneFeature.source();
				sequenceName = geneFeature.seqname();

				//
			} else {
				//deal with cases where no parent gene is given
				geneID = mRNAID;
				geneSource = mRNAsource;
				sequenceName = mRNAFeature.seqname();
			}

			seq = chromosomeSequenceList.get(sequenceName);

			AccessionID geneAccessionID = new AccessionID(geneID);

		  //  FeatureList mRNAChildren = listGenes.selectByAttribute("Parent", mRNAID);
			FeatureList mRNAChildren = featureParentHashMap.get(mRNAID);
			FeatureList cdsFeatures = mRNAChildren.selectByType("CDS");
			FeatureI feature = cdsFeatures.get(0);
			Strand strand = Strand.POSITIVE;

			if (feature.location().isNegative()) {
				strand = Strand.NEGATIVE;
			}
			cdsFeatures = cdsFeatures.sortByStart();







			//String seqName = feature.seqname();
			FeatureI startCodon = null;
			FeatureI stopCodon = null;
			Integer startCodonBegin = null;
			Integer stopCodonEnd = null;
			String startCodonName = "";
			String stopCodonName = "";
			FeatureList startCodonList = mRNAChildren.selectByType("five_prime_UTR");
			if (startCodonList != null && startCodonList.size() > 0) {
				startCodon = startCodonList.get(0);
				if (strand == Strand.NEGATIVE) {
					startCodonBegin = startCodon.location().bioEnd();
				} else {
					startCodonBegin = startCodon.location().bioStart();
				}
				startCodonName = startCodon.getAttribute("ID");
			}

			FeatureList stopCodonList = mRNAChildren.selectByType("three_prime_UTR");

			if (stopCodonList != null && stopCodonList.size() > 0) {
				stopCodon = stopCodonList.get(0);
				if (strand == Strand.NEGATIVE) {
					stopCodonEnd = stopCodon.location().bioStart();
				} else {
					stopCodonEnd = stopCodon.location().bioEnd();
				}
				stopCodonName = stopCodon.getAttribute("ID");

			}




			if (startCodonBegin == null) {
				if (strand == Strand.NEGATIVE) {
					FeatureI firstFeature = cdsFeatures.get(0);

					startCodonBegin = firstFeature.location().bioEnd();
				} else {
					FeatureI firstFeature = cdsFeatures.get(0);

					startCodonBegin = firstFeature.location().bioStart();
				}
			}

			if (stopCodonEnd == null) {
				if (strand == Strand.NEGATIVE) {
					FeatureI lastFeature = cdsFeatures.get(cdsFeatures.size() - 1);
					stopCodonEnd = lastFeature.location().bioStart();
				} else {
					FeatureI lastFeature = cdsFeatures.get(cdsFeatures.size() - 1);
					stopCodonEnd = lastFeature.location().bioEnd();
				}
			}
			//for gtf ordering can be strand based so first is last and last is first
			if (startCodonBegin > stopCodonEnd) {
				int temp = startCodonBegin;
				startCodonBegin = stopCodonEnd;
				stopCodonEnd = temp;
			}



			AccessionID transcriptAccessionID = new AccessionID(mRNAID);
			geneSequence = seq.getGene(geneID);
			if (geneSequence == null) {
				geneSequence = seq.addGene(geneAccessionID, startCodonBegin, stopCodonEnd, strand);
				geneSequence.setSource(geneSource);
				if (geneNote != null && geneNote.length() > 0) {
					geneSequence.addNote(geneNote);
				}
			} else {

				if (startCodonBegin < geneSequence.getBioBegin()) {
					geneSequence.setBioBegin(startCodonBegin);
				}
				if (stopCodonEnd > geneSequence.getBioBegin()) {
					geneSequence.setBioEnd(stopCodonEnd);
				}

			}
			TranscriptSequence transcriptSequence = geneSequence.addTranscript(transcriptAccessionID, startCodonBegin, stopCodonEnd);
			transcriptSequence.setSource(mRNAsource);
			if (mRNANote != null && mRNANote.length() > 0) {
				transcriptSequence.addNote(mRNANote);

			}
			if (startCodon != null) {
				if (startCodonName == null || startCodonName.length() == 0) {
					startCodonName = mRNAID + "-start_codon-" + startCodon.location().bioStart() + "-" + startCodon.location().bioEnd();
				}
				transcriptSequence.addStartCodonSequence(new AccessionID(startCodonName), startCodon.location().bioStart(), startCodon.location().bioEnd());
			}
			if (stopCodon != null) {
				if (stopCodonName == null || stopCodonName.length() == 0) {
					stopCodonName = mRNAID + "-stop_codon-" + stopCodon.location().bioStart() + "-" + stopCodon.location().bioEnd();
				}
				transcriptSequence.addStopCodonSequence(new AccessionID(stopCodonName), stopCodon.location().bioStart(), stopCodon.location().bioEnd());
			}

			for (FeatureI cdsFeature : cdsFeatures) {
				Feature cds = (Feature) cdsFeature;
				String cdsNote = cdsFeature.getAttribute("Note");
				String cdsSource = cds.source();
				String cdsName = cds.getAttribute("ID");
				if (cdsName == null || cdsName.length() == 0) {
					cdsName = mRNAID + "-cds-" + cds.location().bioStart() + "-" + cds.location().bioEnd();
				}
				AccessionID cdsAccessionID = new AccessionID(cdsName);
				ExonSequence exonSequence = geneSequence.addExon(cdsAccessionID, cdsFeature.location().bioStart(), cdsFeature.location().bioEnd());
				exonSequence.setSource(cdsSource);
				if (cdsNote != null && cdsNote.length() > 0) {
					exonSequence.addNote(cdsNote);
				}
				transcriptSequence.addCDS(cdsAccessionID, cdsFeature.location().bioStart(), cdsFeature.location().bioEnd(), cds.frame());
			}
			geneSequence.addIntronsUsingExons();

		}

	}
182377
@Api
	public void setFeatureModel(FeatureModel featureModel) throws LayerException {
		this.featureModel = featureModel;
		if (null != getLayerInfo()) {
			featureModel.setLayerInfo(getLayerInfo());
		}
		filterService.registerFeatureModel(featureModel);
	}
321526
@Override
  public <T extends Feature<T>> T get(FeatureType<T> featureType) {
    @SuppressWarnings("unchecked")
    T feature = (T) featuresByType.get(featureType.type());
    if (feature != null) {
      return feature;
    }
    return featureType.testDefault(this);
  }
694515
static String getValue(final Map<String, Features> featureTable, final String extension) {
        final List<String> buf = new ArrayList<>();
        for (final Features f : featureTable.values()) {
            final List<String> v = f.getFeature(extension);
            if (v != null) {
                buf.addAll(v);
            }
        }
        if (buf.isEmpty()) {
            return null;
        } else {
            return StringUtils.join(buf, ",");
        }
    }
635033
public void setFeature(Feature feature) {
		if (feature != null) {
			this.feature = feature;
			copyToForm(this.feature);
		} else {
			this.feature = null;
			featureForm.clear();
		}
	}
676023
private String getFeatureString(Set<String> featureNames) {
        StringBuilder featureBuilder = new StringBuilder();

        if (featureNames != null) {
            Iterator<String> iter = featureNames.iterator();
            while (iter.hasNext()) {
                featureBuilder.append(iter.next());
                if (iter.hasNext())
                    featureBuilder.append(',');
            }
        }
        return featureBuilder.toString();
    }
344679
protected List<Feature> convertFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> features,
			int maxCoordinates, double startDistance) throws IOException, GeomajasException {
		FeatureIterator<SimpleFeature> iterator = features.features();
		List<Feature> dtoFeatures = new ArrayList<Feature>();
		FeatureConverter converter = new FeatureConverter();
		while (iterator.hasNext()) {
			try {
				SimpleFeature feature = iterator.next();
				dtoFeatures.add(converter.toDto(feature, maxCoordinates));
			} catch (Exception e) {
				continue;
			}
		}
		iterator.close();
		return dtoFeatures;
	}
396797
public static ArrayList<double[]> readText(String featuresFileName, int featureLength) throws Exception {
		ArrayList<double[]> features = new ArrayList<double[]>();
		BufferedReader in = new BufferedReader(new FileReader(new File(featuresFileName)));

		String line;
		while ((line = in.readLine()) != null) {
			String[] stringVals = line.split(",");
			if (stringVals.length != featureLength) {
				in.close();
				throw new Exception("Line contains " + stringVals.length
						+ " comma separated values instead of " + featureLength + "\n" + line);
			}
			double[] vals = new double[featureLength];
			for (int j = 0; j < featureLength; j++) {
				vals[j] = Double.parseDouble(stringVals[j]);
			}
			features.add(vals);
		}
		in.close();
		return features;
	}